Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/venv activation #668

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions build_assets/activate.patch
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
diff -urN bin.orig/activate bin/activate
--- bin.orig/activate 2018-12-27 14:55:13.916461020 +0900
+++ bin/activate 2018-12-27 20:38:35.223248728 +0900
@@ -30,6 +30,15 @@
--- activate.orig 2023-11-01 16:36:41.273318317 +0000
+++ activate 2023-11-01 16:29:45.610264478 +0000
@@ -27,6 +27,17 @@
unset _OLD_VIRTUAL_PS1
fi

+ # Unset exported dev-env variables
+ pushd ${DEVENV_PATH} > /dev/null
+ unset `make env | awk -F= '{print $1}'`
+ popd > /dev/null
+ if [ ! -z "${DEVENV_PATH}" ] ; then
+ pushd ${DEVENV_PATH} > /dev/null
+ unset `make env | awk -F= '{print $1}'`
+ popd > /dev/null
+ fi
+
+ # Unset external env variables
+ declare -f env_deactivate > /dev/null && env_deactivate
+ declare -f venv_deactivate > /dev/null && venv_deactivate
+
unset VIRTUAL_ENV
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
@@ -47,6 +56,11 @@
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
@@ -45,6 +56,11 @@
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH

+# Set external variables
+if [ -f ${VIRTUAL_ENV}/bin/environment.sh ] ; then
+ . ${VIRTUAL_ENV}/bin/environment.sh
+fi
+
# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
3 changes: 1 addition & 2 deletions venv_template.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ venv.$(1)/bin/activate:
pip3.10 install -U setuptools==56.0.0 && \
pip3.10 install -Ur requirements.txt
@echo "Applying activate script patch"
patch -R --dry-run -p1 -s -f -d venv.$(1)/bin/ < build_assets/activate.patch || \
patch -p1 -d venv.$(1)/bin/ < build_assets/activate.patch
patch -b -d venv.$(1)/bin/ < build_assets/activate.patch

venv.$(1)/bin/environment.sh: | venv/$(1)/environment.sh
ln -s ../../venv/$(1)/environment.sh venv.$(1)/bin/environment.sh
Expand Down
Loading