pyenv initialization update

- pyenv init optional
- check pyenv command before populate PATH
- always load user site packages directory
This commit is contained in:
arshavindn 2018-08-16 12:09:53 +07:00
parent dacef14214
commit 192ece1f62
2 changed files with 29 additions and 26 deletions

View file

@ -26,6 +26,10 @@ Local Python Installation
[pyenv][4] builds and installs multiple Python versions locally in the home
directory.
```sh
zstyle ':prezto:module:python:pyenv' auto-init 'yes'
```
This module prepends the pyenv directory to the path variable to enable the
execution of `pyenv`.

View file

@ -7,21 +7,24 @@
# Patrick Bos <egpbos@gmail.com>
#
if zstyle -t ':prezto:module:python:pyenv' auto-init 'yes'; then
# Load manually installed pyenv into the shell session.
if [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then
if [[ -s "$HOME/.pyenv/bin/pyenv" ]] && (( ! $+commands[pyenv] )); then
path=("$HOME/.pyenv/bin" $path)
export PYENV_ROOT=$(pyenv root)
eval "$(pyenv init - --no-rehash zsh)"
fi
# Load package manager installed pyenv into the shell session.
elif (( $+commands[pyenv] )); then
export PYENV_ROOT=$(pyenv root)
# Return if requirements are not found.
if (( ! $+commands[python] && ! $+commands[pyenv] )); then
return 1
elif (( $+commands[python] )); then
if (( $+commands[pyenv] )) && [[ -z "$PYENV_SHELL" ]]; then
eval "$(pyenv init - --no-rehash zsh)"
fi
# Prepend PEP 370 per user site packages directory, which defaults to
# ~/Library/Python on macOS and ~/.local elsewhere, to PATH. The
# path can be overridden using PYTHONUSERBASE.
else
if [[ -n "$PYTHONUSERBASE" ]]; then
path=($PYTHONUSERBASE/bin $path)
elif [[ "$OSTYPE" == darwin* ]]; then
@ -31,10 +34,6 @@ else
path=($HOME/.local/bin $path)
fi
fi
# Return if requirements are not found.
if (( ! $+commands[python] && ! $+commands[pyenv] )); then
return 1
fi
function _python-workon-cwd {