File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export PYTHONEXECUTABLE
7070# unset PYTHONHOME if set
7171# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
7272# could use `if (set -u; : $PYTHONHOME) ;` in bash.
73- _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
73+ _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-_activate_undef }"
7474unset PYTHONHOME
7575
7676_OLD_VIRTUAL_PATH="$PATH"
@@ -85,6 +85,24 @@ _OLD_VIRTUAL_PATH="$PATH"
8585# can provide some fallback handling around runfiles too.
8686{{RUNFILES_INTERPRETER}}
8787
88+ _abspath() {
89+ "${PYTHONEXECUTABLE}" -c 'import os, sys; print(os.path.abspath(sys.argv[1]))' "$@"
90+ }
91+
92+ # Re-export abspath'd vars
93+ # This allows us to avoid relative path issues without incurring sandbox escapes
94+ VIRTUAL_ENV="$(_abspath "${VIRTUAL_ENV}")"
95+ export VIRTUAL_ENV
96+
97+ PYTHONEXECUTABLE="$(_abspath "${PYTHONEXECUTABLE}")"
98+ export PYTHONEXECUTABLE
99+
100+ if [ -n "${PYTHONHOME:-}" ]; then
101+ PYTHONHOME="$(_abspath "${PYTHONHOME}")"
102+ export PYTHONHOME
103+ fi
104+
105+ # Now we can put the venv's absolute bin on the path
88106PATH="$VIRTUAL_ENV/bin:$PATH"
89107export PATH
90108
Original file line number Diff line number Diff line change 1- # --- Runfiles-based interpreter setup --
1+ # --- Runfiles-based interpreter setup ---
22
33# If the runfiles dir is unset AND we will fail to find a runfiles manifest
44# based on inspecting $0, we need to try something different.
You can’t perform that action at this time.
0 commit comments