summaryrefslogtreecommitdiff
path: root/evergreen/functions/venv_adjust.sh
blob: bccdf847f80d5491f335ec1a66a41bdf804b0008 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
. "$DIR/../prelude_python.sh"

set -o errexit
set -o verbose

python_loc=$(which ${python})
pushd venv
venv_dir=$(pwd)
popd

# Update virtual env directory in activate script
if [ "Windows_NT" = "$OS" ]; then
  sed -i -e "s:VIRTUAL_ENV=\".*\":VIRTUAL_ENV=\"$venv_dir\":" "$venv_dir/Scripts/activate"
else
  sed -i -e "s:VIRTUAL_ENV=\".*\":VIRTUAL_ENV=\"$venv_dir\":" "$venv_dir/bin/activate"
fi

# Add back python symlinks on linux platforms
if [ "Windows_NT" = "$OS" ]; then
  exit 0
fi

cd "$venv_dir/bin"

rm python python3
ln -s "$python_loc" python3
ln -s python3 python
python3_dot_locs=$(ls python3.*)
for p in $python3_dot_locs; do
  rm "$p"
  ln -s python3 "$p"
done