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

feat: Avoid repeatedly adding virtual env to path variables #45

Merged
merged 1 commit into from
Nov 18, 2023
Merged
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
16 changes: 13 additions & 3 deletions cvmfs-venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ cvmfs-venv-rebase () {
# Update value of PATH to restore at deactivate
_OLD_VIRTUAL_PATH="\${_PATH}"
# Prepend \$VIRTUAL_ENV/bin to front of PATH
_PATH="\${VIRTUAL_ENV_BIN}:\${_PATH}"
# In the event that VIRTUAL_ENV_BIN already happened
# to be at the head of PATH, do nothing to avoid
# having the same directory path twice consecutively.
if [ "\${_PATH%%:*}" != "\${VIRTUAL_ENV_BIN}" ] ; then
_PATH="\${VIRTUAL_ENV_BIN}:\${_PATH}"
fi
export PATH="\${_PATH}"

unset VIRTUAL_ENV_BIN
Expand All @@ -259,8 +264,13 @@ cvmfs-venv-rebase () {
_PYTHONPATH="\${_PYTHONPATH%:}"
# Update value of PYTHONPATH to restore at deactivate
_OLD_VIRTUAL_PYTHONPATH="\${_PYTHONPATH}"
# Prepend _VIRTUAL_SITE_PACKAGES_DIRECTORY_TREE to front of PYTHONPATH
_PYTHONPATH="\${_VIRTUAL_SITE_PACKAGES}:\${_PYTHONPATH}"
# Prepend _VIRTUAL_SITE_PACKAGES to front of PYTHONPATH
# In the event that VIRTUAL_SITE_PACKAGES already happened
# to be at the head of PYTHONPATH, do nothing to avoid
# having the same directory path twice consecutively.
if [ "\${_PYTHONPATH%%:*}" != "\${_VIRTUAL_SITE_PACKAGES}" ] ; then
_PYTHONPATH="\${_VIRTUAL_SITE_PACKAGES}:\${_PYTHONPATH}"
fi
export PYTHONPATH="\${_PYTHONPATH}"

unset _PYTHONPATH
Expand Down