From b91bc8a1d2cf76e7efcb18c07078e78b05c2f2eb Mon Sep 17 00:00:00 2001 From: Marcos Trovilho Date: Sat, 16 Feb 2013 14:48:44 -0200 Subject: [PATCH] add pyenv to python module --- modules/python/README.md | 12 +++++++++++- modules/python/init.zsh | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/python/README.md b/modules/python/README.md index c48f4ea3..bd904d6a 100644 --- a/modules/python/README.md +++ b/modules/python/README.md @@ -16,6 +16,16 @@ execution of `pythonz`. Install Python versions with `pythonz install` into *~/.pythonz/pythons*. +pyenv +----- + +An alternative pythonz is to use [pyenv][6], which allows for switching between +multiple, isolated Python installations in the home directory. + +### Usage + +Install Python versions with `pyenv install` into *~/.pyenv/versions*. + Local Package Installation -------------------------- @@ -107,4 +117,4 @@ Authors [3]: http://pypi.python.org/pypi/virtualenv [4]: http://saghul.github.com/pythonz/ [5]: https://github.com/sorin-ionescu/prezto/issues - +[6]: https://github.com/yyuu/pyenv diff --git a/modules/python/init.zsh b/modules/python/init.zsh index a72f01f9..6b5b4f1c 100644 --- a/modules/python/init.zsh +++ b/modules/python/init.zsh @@ -9,10 +9,20 @@ # Load pythonz into the shell session. if [[ -s $HOME/.pythonz/bin/pythonz ]]; then path=($HOME/.pythonz/bin $path) + +# Load manually installed pyenv into the shell session. +elif [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then + path=("$HOME/.pyenv/bin" $path) + eval "$(pyenv init -)" + +# Load package manager installed pyenv into the shell session. +elif (( $+commands[pyenv] )); then + eval "$(pyenv init -)" + fi # Return if requirements are not found. -if (( ! $+commands[python] && ! $+commands[pythonz] )); then +if (( ! $+commands[python] && ! ( $+commands[pythonz] || $+commands[pyenv] ) )); then return 1 fi