Browse Source

Fix deactivation issue with `system` version

$ pyenv global system
    $ pyenv shell venv
    (venv) $ pyenv shell --unset
    (venv) $ pyenv version
    system (set by /home/yamashita/.pyenv/version)
    (venv) $ pyenv which python
    /home/yamashita/.pyenv/versions/venv/bin/python # <-- should be `/usr/bin/python` (system)
pull/27/head
Yamashita Yuu 10 years ago
parent
commit
21e999cc7c
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      bin/pyenv-virtualenv-init

+ 12
- 6
bin/pyenv-virtualenv-init View File

@ -66,8 +66,10 @@ case "$shell" in
bash )
cat <<EOS
_pyenv_virtualenv_hook() {
if [[ "\$VIRTUAL_ENV" != "\$(pyenv prefix)" ]]; then
pyenv deactivate;
if [[ "\$(pyenv version-name)" == "system" ]]; then
pyenv deactivate || true;
elif [[ "\$VIRTUAL_ENV" != "\$(pyenv prefix)" ]]; then
pyenv deactivate || true;
pyenv activate 2>/dev/null || true
fi
};
@ -79,8 +81,10 @@ EOS
fish )
cat <<EOS
function _pyenv_virtualenv_hook --on-event fish_prompt;
if [ "\$VIRTUAL_ENV" != (pyenv prefix) ]
eval (pyenv sh-deactivate)
if [ (pyenv version-name) = "system" ]
eval (pyenv sh-deactivate); or true
else if [ "\$VIRTUAL_ENV" != (pyenv prefix) ]
eval (pyenv sh-deactivate); or true
eval (pyenv sh-activate 2>/dev/null); or true
end
end
@ -89,8 +93,10 @@ EOS
zsh )
cat <<EOS
_pyenv_virtualenv_hook() {
if [[ "\$VIRTUAL_ENV" != "\$(pyenv prefix)" ]]; then
pyenv deactivate
if [[ "\$(pyenv version-name)" == "system" ]]; then
pyenv deactivate || true
elif [[ "\$VIRTUAL_ENV" != "\$(pyenv prefix)" ]]; then
pyenv deactivate || true
pyenv activate 2>/dev/null || true
fi
}

Loading…
Cancel
Save