pyenv initialization update
- pyenv init optional - check pyenv command before populate PATH - always load user site packages directory
This commit is contained in:
parent
dacef14214
commit
192ece1f62
2 changed files with 29 additions and 26 deletions
|
@ -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`.
|
||||
|
||||
|
|
|
@ -7,34 +7,33 @@
|
|||
# Patrick Bos <egpbos@gmail.com>
|
||||
#
|
||||
|
||||
# Load manually installed pyenv into the shell session.
|
||||
if [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then
|
||||
path=("$HOME/.pyenv/bin" $path)
|
||||
export PYENV_ROOT=$(pyenv root)
|
||||
eval "$(pyenv init - --no-rehash zsh)"
|
||||
|
||||
# Load package manager installed pyenv into the shell session.
|
||||
elif (( $+commands[pyenv] )); then
|
||||
export PYENV_ROOT=$(pyenv root)
|
||||
eval "$(pyenv init - --no-rehash zsh)"
|
||||
|
||||
# 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
|
||||
path=($HOME/Library/Python/*/bin(N) $path)
|
||||
else
|
||||
# This is subject to change.
|
||||
path=($HOME/.local/bin $path)
|
||||
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" ]] && (( ! $+commands[pyenv] )); then
|
||||
path=("$HOME/.pyenv/bin" $path)
|
||||
export PYENV_ROOT=$(pyenv root)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Return if requirements are not found.
|
||||
if (( ! $+commands[python] && ! $+commands[pyenv] )); then
|
||||
return 1
|
||||
# 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.
|
||||
if [[ -n "$PYTHONUSERBASE" ]]; then
|
||||
path=($PYTHONUSERBASE/bin $path)
|
||||
elif [[ "$OSTYPE" == darwin* ]]; then
|
||||
path=($HOME/Library/Python/*/bin(N) $path)
|
||||
else
|
||||
# This is subject to change.
|
||||
path=($HOME/.local/bin $path)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
function _python-workon-cwd {
|
||||
|
|
Loading…
Add table
Reference in a new issue