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

This commit is contained in:
Yamashita Yuu
2014-07-04 15:44:55 +09:00
parent e2e69b3b38
commit 7e8223eac1
6 changed files with 38 additions and 24 deletions

View File

@@ -78,13 +78,15 @@ case "$shell" in
fish )
cat <<EOS
set -e PYENV_DEACTIVATE;
. "$(pyenv-prefix "${versions}")/bin/activate.fish";
setenv PYENV_ACTIVATE "$(pyenv-prefix "${versions}")";
. "\${PYENV_ACTIVATE}/bin/activate.fish";
EOS
;;
* )
cat <<EOS
unset PYENV_DEACTIVATE;
source "$(pyenv-prefix "${versions}")/bin/activate";
export PYENV_ACTIVATE="$(pyenv-prefix "${versions}")";
source "\${PYENV_ACTIVATE}/bin/activate";
EOS
;;
esac

View File

@@ -14,7 +14,8 @@ case "$shell" in
fish )
cat <<EOS
if functions -q deactivate
setenv PYENV_DEACTIVATE "\$VIRTUAL_ENV";
setenv PYENV_DEACTIVATE "\$PYENV_ACTIVATE";
set -e PYENV_ACTIVATE;
deactivate;
end;
EOS
@@ -22,7 +23,8 @@ EOS
* )
cat <<EOS
if declare -f deactivate 1>/dev/null 2>&1; then
export PYENV_DEACTIVATE="\$VIRTUAL_ENV";
export PYENV_DEACTIVATE="\$PYENV_ACTIVATE";
unset PYENV_ACTIVATE;
deactivate;
fi;
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); or true
return 0
end
if [ "\$VIRTUAL_ENV" != (pyenv prefix) ]
if [ "\$PYENV_ACTIVATE" != (pyenv prefix) ]
eval (pyenv sh-deactivate); or true
eval (pyenv sh-activate 2>/dev/null); or true
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 || true
return 0
fi
if [ "x\$VIRTUAL_ENV" != "x\`pyenv prefix\`" ]; then
if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then
pyenv deactivate || true
pyenv activate 2>/dev/null || true
fi