Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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`.

Expand Down
44 changes: 19 additions & 25 deletions modules/python/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,31 @@
# Patrick Bos <egpbos@gmail.com>
#

# Load manually installed pyenv into the path
if [[ -n "$PYENV_ROOT" && -s "$PYENV_ROOT/bin/pyenv" ]]; then
path=("$PYENV_ROOT/bin" $path)
elif [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then
# Load manually installed pyenv into the shell session.
if [[ -s "$HOME/.pyenv/bin/pyenv" ]] && (( ! $+commands[pyenv] )); then
path=("$HOME/.pyenv/bin" $path)
fi

# Load pyenv into the current python session
if (( $+commands[pyenv] )); then
if [[ -z "$PYENV_ROOT" ]]; then
export PYENV_ROOT=$(pyenv root)
fi
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
export PYENV_ROOT=$(pyenv root)
fi

# 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

function _python-workon-cwd {
Expand Down