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
|
[pyenv][4] builds and installs multiple Python versions locally in the home
|
||||||
directory.
|
directory.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
zstyle ':prezto:module:python:pyenv' auto-init 'yes'
|
||||||
|
```
|
||||||
|
|
||||||
This module prepends the pyenv directory to the path variable to enable the
|
This module prepends the pyenv directory to the path variable to enable the
|
||||||
execution of `pyenv`.
|
execution of `pyenv`.
|
||||||
|
|
||||||
|
|
|
@ -7,34 +7,33 @@
|
||||||
# Patrick Bos <egpbos@gmail.com>
|
# Patrick Bos <egpbos@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
# Load manually installed pyenv into the shell session.
|
if zstyle -t ':prezto:module:python:pyenv' auto-init 'yes'; then
|
||||||
if [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then
|
# Load manually installed pyenv into the shell session.
|
||||||
path=("$HOME/.pyenv/bin" $path)
|
if [[ -s "$HOME/.pyenv/bin/pyenv" ]] && (( ! $+commands[pyenv] )); then
|
||||||
export PYENV_ROOT=$(pyenv root)
|
path=("$HOME/.pyenv/bin" $path)
|
||||||
eval "$(pyenv init - --no-rehash zsh)"
|
export PYENV_ROOT=$(pyenv root)
|
||||||
|
|
||||||
# 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)
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Return if requirements are not found.
|
# Return if requirements are not found.
|
||||||
if (( ! $+commands[python] && ! $+commands[pyenv] )); then
|
if (( ! $+commands[python] && ! $+commands[pyenv] )); then
|
||||||
return 1
|
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
|
fi
|
||||||
|
|
||||||
function _python-workon-cwd {
|
function _python-workon-cwd {
|
||||||
|
|
Loading…
Add table
Reference in a new issue