summaryrefslogtreecommitdiff
path: root/evergreen/functions/venv_adjust.sh
diff options
context:
space:
mode:
Diffstat (limited to 'evergreen/functions/venv_adjust.sh')
-rw-r--r--evergreen/functions/venv_adjust.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/evergreen/functions/venv_adjust.sh b/evergreen/functions/venv_adjust.sh
new file mode 100644
index 00000000000..bccdf847f80
--- /dev/null
+++ b/evergreen/functions/venv_adjust.sh
@@ -0,0 +1,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