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