mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-13 14:03:53 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72cf0e1b1b | ||
|
|
41ee00574c | ||
|
|
f594876f31 | ||
|
|
521576e8c4 | ||
|
|
0048516a7d | ||
|
|
f657fad926 |
@@ -1,5 +1,11 @@
|
||||
## Version History
|
||||
|
||||
#### 20151103
|
||||
|
||||
* Passing return value from executed command. (#100)
|
||||
* Add workaround for commands installed in a virtual environment created by `pyvenv` (#62)
|
||||
* init: zsh: prepend hook to `precmd_functions` (#101)
|
||||
|
||||
#### 20151006
|
||||
|
||||
* Ignore user's site-packages on ensurepip/get-pip (#89)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# -f/--force Install even if the version appears to be installed already
|
||||
#
|
||||
|
||||
PYENV_VIRTUALENV_VERSION="20151006"
|
||||
PYENV_VIRTUALENV_VERSION="20151103"
|
||||
|
||||
set -e
|
||||
[ -n "$PYENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -77,11 +77,12 @@ fish )
|
||||
cat <<EOS
|
||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
set -l PYENV_PREFIX (pyenv prefix 2>/dev/null; or true)
|
||||
set -l ret \$status
|
||||
if [ -n "\$PYENV_ACTIVATE" ]
|
||||
if [ (pyenv version-name 2>/dev/null; or true) = "system" ]
|
||||
pyenv deactivate --no-error --verbose
|
||||
set -e PYENV_DEACTIVATE
|
||||
return 0
|
||||
return \$ret
|
||||
end
|
||||
if [ "\$PYENV_ACTIVATE" != "\$PYENV_PREFIX" ]
|
||||
if pyenv deactivate --no-error --verbose
|
||||
@@ -96,6 +97,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
pyenv activate --no-error --verbose; or true
|
||||
end
|
||||
end
|
||||
return \$ret
|
||||
end
|
||||
EOS
|
||||
;;
|
||||
@@ -113,11 +115,12 @@ esac
|
||||
|
||||
if [[ "$shell" != "fish" ]]; then
|
||||
cat <<EOS
|
||||
local ret=\$?
|
||||
if [ -n "\$PYENV_ACTIVATE" ]; then
|
||||
if [ "\$(pyenv version-name 2>/dev/null || true)" = "system" ]; then
|
||||
eval "\$(pyenv sh-deactivate --no-error --verbose)"
|
||||
unset PYENV_DEACTIVATE
|
||||
return 0
|
||||
return \$ret
|
||||
fi
|
||||
if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
||||
if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then
|
||||
@@ -132,6 +135,7 @@ if [[ "$shell" != "fish" ]]; then
|
||||
eval "\$(pyenv sh-activate --no-error --verbose)" || true
|
||||
fi
|
||||
fi
|
||||
return \$ret
|
||||
};
|
||||
EOS
|
||||
|
||||
@@ -147,7 +151,7 @@ EOS
|
||||
cat <<EOS
|
||||
typeset -g -a precmd_functions
|
||||
if [[ -z \$precmd_functions[(r)_pyenv_virtualenv_hook] ]]; then
|
||||
precmd_functions+=_pyenv_virtualenv_hook;
|
||||
precmd_functions=(_pyenv_virtualenv_hook \$precmd_functions);
|
||||
fi
|
||||
EOS
|
||||
;;
|
||||
|
||||
@@ -6,10 +6,22 @@
|
||||
if [ ! -x "${PYENV_COMMAND_PATH}" ]; then
|
||||
virtualenv_prefix="$(pyenv-virtualenv-prefix 2>/dev/null || true)"
|
||||
if [ -d "${virtualenv_prefix}" ]; then
|
||||
shopt -s nullglob
|
||||
no_global_site_packages="$(echo "$(pyenv-prefix)/lib/"*"/no-global-site-packages.txt")"
|
||||
shopt -u nullglob
|
||||
if [ ! -f "${no_global_site_packages}" ]; then
|
||||
unset include_system_site_packages
|
||||
if [ -f "$(pyenv-prefix)/pyvenv.cfg" ]; then
|
||||
# pyvenv
|
||||
if grep -q -i "include-system-site-packages *= *true" "$(pyenv-prefix)/pyvenv.cfg" 1>/dev/null 2>&1; then
|
||||
include_system_site_packages=1
|
||||
fi
|
||||
else
|
||||
# virtualenv
|
||||
shopt -s nullglob
|
||||
no_global_site_packages="$(echo "$(pyenv-prefix)/lib/"*"/no-global-site-packages.txt")"
|
||||
shopt -u nullglob
|
||||
if [ ! -f "${no_global_site_packages}" ]; then
|
||||
include_system_site_packages=1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${include_system_site_packages}" ]; then
|
||||
# virtualenv is created with `--system-site-packages`
|
||||
virtualenv_command_path="${virtualenv_prefix}/bin/${PYENV_COMMAND_PATH##*/}"
|
||||
if [ -x "${virtualenv_command_path}" ]; then
|
||||
|
||||
@@ -51,11 +51,12 @@ load test_helper
|
||||
assert_output <<EOS
|
||||
export PYENV_VIRTUALENV_INIT=1;
|
||||
_pyenv_virtualenv_hook() {
|
||||
local ret=\$?
|
||||
if [ -n "\$PYENV_ACTIVATE" ]; then
|
||||
if [ "\$(pyenv version-name 2>/dev/null || true)" = "system" ]; then
|
||||
eval "\$(pyenv sh-deactivate --no-error --verbose)"
|
||||
unset PYENV_DEACTIVATE
|
||||
return 0
|
||||
return \$ret
|
||||
fi
|
||||
if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
||||
if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then
|
||||
@@ -70,6 +71,7 @@ _pyenv_virtualenv_hook() {
|
||||
eval "\$(pyenv sh-activate --no-error --verbose)" || true
|
||||
fi
|
||||
fi
|
||||
return \$ret
|
||||
};
|
||||
if ! [[ "\$PROMPT_COMMAND" =~ _pyenv_virtualenv_hook ]]; then
|
||||
PROMPT_COMMAND="_pyenv_virtualenv_hook;\$PROMPT_COMMAND";
|
||||
@@ -84,11 +86,12 @@ EOS
|
||||
setenv PYENV_VIRTUALENV_INIT 1;
|
||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
set -l PYENV_PREFIX (pyenv prefix 2>/dev/null; or true)
|
||||
set -l ret \$status
|
||||
if [ -n "\$PYENV_ACTIVATE" ]
|
||||
if [ (pyenv version-name 2>/dev/null; or true) = "system" ]
|
||||
pyenv deactivate --no-error --verbose
|
||||
set -e PYENV_DEACTIVATE
|
||||
return 0
|
||||
return \$ret
|
||||
end
|
||||
if [ "\$PYENV_ACTIVATE" != "\$PYENV_PREFIX" ]
|
||||
if pyenv deactivate --no-error --verbose
|
||||
@@ -103,6 +106,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
pyenv activate --no-error --verbose; or true
|
||||
end
|
||||
end
|
||||
return \$ret
|
||||
end
|
||||
EOS
|
||||
}
|
||||
@@ -113,11 +117,12 @@ EOS
|
||||
assert_output <<EOS
|
||||
export PYENV_VIRTUALENV_INIT=1;
|
||||
_pyenv_virtualenv_hook() {
|
||||
local ret=\$?
|
||||
if [ -n "\$PYENV_ACTIVATE" ]; then
|
||||
if [ "\$(pyenv version-name 2>/dev/null || true)" = "system" ]; then
|
||||
eval "\$(pyenv sh-deactivate --no-error --verbose)"
|
||||
unset PYENV_DEACTIVATE
|
||||
return 0
|
||||
return \$ret
|
||||
fi
|
||||
if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
||||
if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then
|
||||
@@ -132,10 +137,11 @@ _pyenv_virtualenv_hook() {
|
||||
eval "\$(pyenv sh-activate --no-error --verbose)" || true
|
||||
fi
|
||||
fi
|
||||
return \$ret
|
||||
};
|
||||
typeset -g -a precmd_functions
|
||||
if [[ -z \$precmd_functions[(r)_pyenv_virtualenv_hook] ]]; then
|
||||
precmd_functions+=_pyenv_virtualenv_hook;
|
||||
precmd_functions=(_pyenv_virtualenv_hook \$precmd_functions);
|
||||
fi
|
||||
EOS
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ load test_helper
|
||||
|
||||
setup() {
|
||||
export PYENV_ROOT="${TMP}/pyenv"
|
||||
export PYENV_VIRTUALENV_VERSION="20151006"
|
||||
export PYENV_VIRTUALENV_VERSION="20151103"
|
||||
}
|
||||
|
||||
@test "display virtualenv version" {
|
||||
|
||||
Reference in New Issue
Block a user