From 459238b2bbbfd78b233209fb66906d388e1fbe0b Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 20 Aug 2013 08:21:17 -0400 Subject: [PATCH] Replace pythonz with pyenv Depending on Python to manage Python is silly. --- modules/python/README.md | 20 +++++-------------- modules/python/init.zsh | 43 ++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/modules/python/README.md b/modules/python/README.md index c48f4ea3..8e8c8f01 100644 --- a/modules/python/README.md +++ b/modules/python/README.md @@ -6,15 +6,15 @@ Enables local Python and local Python package installation. Local Python Installation ------------------------- -[pythonz][4] builds and installs multiple Python versions locally in the home +[pyenv][4] builds and installs multiple Python versions locally in the home directory. -This module prepends the pythonz directory to the path variable to enable the -execution of `pythonz`. +This module prepends the pyenv directory to the path variable to enable the +execution of `pyenv`. ### Usage -Install Python versions with `pythonz install` into *~/.pythonz/pythons*. +Install Python versions with `pyenv install` into *~/.pyenv/versions*. Local Package Installation -------------------------- @@ -66,16 +66,6 @@ Aliases - `py` is short for `python`. -### Pythonz - - - `pyz` is short for `pythonz`. - - `pyzc` removes stale source folders and archives. - - `pyzi` installs Python versions. - - `pyzl` lists installed Python versions. - - `pyzL` lists available Python versions. - - `pyzu` updates itself to the latest version. - - `pyzx` uninstalls Python versions. - Functions --------- @@ -105,6 +95,6 @@ Authors [1]: http://www.python.org/dev/peps/pep-0370/ [2]: http://www.doughellmann.com/projects/virtualenvwrapper/ [3]: http://pypi.python.org/pypi/virtualenv -[4]: http://saghul.github.com/pythonz/ +[4]: https://github.com/yyuu/pyenv [5]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/python/init.zsh b/modules/python/init.zsh index a72f01f9..fa9175e5 100644 --- a/modules/python/init.zsh +++ b/modules/python/init.zsh @@ -6,29 +6,35 @@ # Sebastian Wiesner # -# Load pythonz into the shell session. -if [[ -s $HOME/.pythonz/bin/pythonz ]]; then - path=($HOME/.pythonz/bin $path) -fi +# Load manually installed pyenv into the shell session. +if [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then + path=("$HOME/.pyenv/bin" $path) + eval "$(pyenv init -)" -# Return if requirements are not found. -if (( ! $+commands[python] && ! $+commands[pythonz] )); then - return 1 -fi +# Load package manager installed pyenv into the shell session. +elif (( $+commands[pyenv] )); then + eval "$(pyenv init -)" # Prepend PEP 370 per user site packages directory, which defaults to # ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH. -if [[ "$OSTYPE" == darwin* ]]; then - path=($HOME/Library/Python/*/bin(N) $path) else - # This is subject to change. - path=($HOME/.local/bin $path) + if [[ "$OSTYPE" == darwin* ]]; then + path=($HOME/Library/Python/*/bin(N) $path) + else + # This is subject to change. + path=($HOME/.local/bin $path) + fi +fi + +# Return if requirements are not found. +if (( ! $+commands[python] && ! $+commands[pyenv] )); then + return 1 fi # Load virtualenvwrapper into the shell session. if (( $+commands[virtualenvwrapper_lazy.sh] )); then # Set the directory where virtual environments are stored. - export WORKON_HOME=$HOME/.virtualenvs + export WORKON_HOME="$HOME/.virtualenvs" # Disable the virtualenv prompt. VIRTUAL_ENV_DISABLE_PROMPT=1 @@ -42,14 +48,3 @@ fi alias py='python' -# pythonz -if (( $+commands[pythonz] )); then - alias pyz='pythonz' - alias pyzc='pythonz cleanup' - alias pyzi='pythonz install' - alias pyzl='pythonz list' - alias pyzL='pythonz list -a' - alias pyzu='pythonz update' - alias pyzx='pythonz uninstall' -fi -