6 Commits

Author SHA1 Message Date
Yamashita, Yuu
72cf0e1b1b v20151103 2015-11-03 13:36:45 +00:00
Yamashita, Yuu
41ee00574c Merge pull request #101 from blueyed/prepend-to-precmd
init: zsh: prepend hook to precmd_functions
2015-11-03 05:25:20 +09:00
Daniel Hahler
f594876f31 init: zsh: prepend hook to precmd_functions
This makes sure that $VIRTUAL_ENV is handled already in other precmd
functions, especially your prompt.
2015-11-02 17:52:59 +01:00
Yamashita, Yuu
521576e8c4 workaround for pyvenv --system-site-packages (#62) 2015-10-30 01:55:46 +00:00
Yamashita, Yuu
0048516a7d Merge pull request #100 from bartoszj/master
Passing return value from executed command.
2015-10-16 07:07:33 +09:00
Bartosz Janda
f657fad926 Passing return value from executed command. 2015-10-15 20:37:00 +02:00
6 changed files with 41 additions and 13 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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
;;

View File

@@ -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

View File

@@ -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
}

View File

@@ -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" {