Fix issues with manual activation of virtual environments (#34)

This commit is contained in:
Yamashita Yuu
2014-07-04 22:55:06 +09:00
parent be18fd294e
commit abfda4bac9
6 changed files with 54 additions and 33 deletions

View File

@@ -99,17 +99,20 @@ if [ -z "$no_shell" ]; then
echo "pyenv shell \"${versions}\";"
fi
prefix="$(pyenv-prefix "${versions}")"
case "$shell" in
fish )
cat <<EOS
set -e PYENV_DEACTIVATE;
. "$(pyenv-prefix "${versions}")/bin/activate.fish";
setenv PYENV_ACTIVATE "${prefix}";
. "${prefix}/bin/activate.fish";
EOS
;;
* )
cat <<EOS
unset PYENV_DEACTIVATE;
source "$(pyenv-prefix "${versions}")/bin/activate";
export PYENV_ACTIVATE="${prefix}";
source "${prefix}/bin/activate";
EOS
;;
esac

View File

@@ -38,7 +38,7 @@ fish )
esac
if [ -n "$VERBOSE" ]; then
echo " echo \"pyenv-virtualenv: deactivate ${VIRTUAL_ENV##*/}\" 1>&2;"
echo " echo \"pyenv-virtualenv: deactivate ${PYENV_ACTIVATE##*/}\" 1>&2;"
fi
if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then
@@ -50,14 +50,16 @@ fi
case "$shell" in
fish )
cat <<EOS
setenv PYENV_DEACTIVATE "$VIRTUAL_ENV";
setenv PYENV_DEACTIVATE "$PYENV_ACTIVATE";
set -e PYENV_ACTIVATE;
deactivate;
else;
EOS
;;
* )
cat <<EOS
export PYENV_DEACTIVATE="$VIRTUAL_ENV";
export PYENV_DEACTIVATE="$PYENV_ACTIVATE";
unset PYENV_ACTIVATE;
deactivate;
else
EOS

View File

@@ -75,12 +75,12 @@ case "$shell" in
fish )
cat <<EOS
function _pyenv_virtualenv_hook --on-event fish_prompt;
if [ -n "\$VIRTUAL_ENV" ]
if [ -n "\$PYENV_ACTIVATE" ]
if [ (pyenv version-name) = "system" ]
eval (pyenv sh-deactivate --no-error --verbose)
return 0
end
if [ "\$VIRTUAL_ENV" != (pyenv prefix) ]
if [ "\$PYENV_ACTIVATE" != (pyenv prefix) ]
eval (pyenv sh-deactivate --no-error --verbose)
eval (pyenv sh-activate --no-error --verbose)
end
@@ -106,12 +106,12 @@ esac
if [[ "$shell" != "fish" ]]; then
cat <<EOS
if [ -n "\$VIRTUAL_ENV" ]; then
if [ -n "\$PYENV_ACTIVATE" ]; then
if [ "x\`pyenv version-name\`" = "xsystem" ]; then
pyenv deactivate --no-error --verbose
return 0
fi
if [ "x\$VIRTUAL_ENV" != "x\`pyenv prefix\`" ]; then
if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then
pyenv deactivate --no-error --verbose
pyenv activate --no-error --verbose
fi