From 8d7e3e27c7577175330241f0279a805c471d3bf8 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Fri, 4 Aug 2017 09:53:01 -0500 Subject: [PATCH] [python] Detect availability of virtualenv plugins as well as pyenv Just having 'pyenv' available doesn't imply availability of virtualenv pyenv plugins. Check for availability of virtualenv plugins as well before attempting to use pyenv wrapper for virtualenv. --- modules/python/init.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/python/init.zsh b/modules/python/init.zsh index 759b903..715ca25 100644 --- a/modules/python/init.zsh +++ b/modules/python/init.zsh @@ -92,16 +92,16 @@ if (( $+VIRTUALENVWRAPPER_VIRTUALENV || $+commands[virtualenv] )) && \ # Disable the virtualenv prompt. VIRTUAL_ENV_DISABLE_PROMPT=1 - if (( $+commands[pyenv] )); then - if (( $+commands[pyenv-virtualenv-init] )); then - eval "$(pyenv virtualenv-init -)" - fi + # Enable 'virtualenv' with 'pyenv'. + if (( $+commands[pyenv] && $+commands[pyenv-virtualenv-init] )); then + eval "$(pyenv virtualenv-init -)" + # Optionall activate 'virtualenvwrapper' with 'pyenv' is available. if (( $#commands[(i)pyenv-virtualenvwrapper(_lazy|)] )); then pyenv "${${(@O)commands[(I)pyenv-virtualenvwrapper(_lazy|)]}[1]#pyenv-}" fi else - # Try 'virtualenvwrapper' without 'pyenv' wrapper in '$path' and other - # known locations on a Debian based system. + # Fallback to 'virtualenvwrapper' without 'pyenv' wrapper in '$path' + # and other known locations on a Debian based system. virtenv_sources=( ${(@Ov)commands[(I)virtualenvwrapper(_lazy|).sh]} /usr/share/virtualenvwrapper/virtualenvwrapper(_lazy|).sh(OnN)