From 09313c0c8455f7967ff540a275ebf92ea1cc2815 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Mon, 11 Dec 2017 11:01:40 -0800 Subject: [PATCH] python: make a reasonable guess about virtualenvwrapper python location Fixes #1416 --- modules/autosuggestions/external | 2 +- modules/python/README.md | 18 +++++++++++++++--- modules/python/init.zsh | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/modules/autosuggestions/external b/modules/autosuggestions/external index 15931f0..9f9237a 160000 --- a/modules/autosuggestions/external +++ b/modules/autosuggestions/external @@ -1 +1 @@ -Subproject commit 15931f04ffac91a2f9a1a044b6b3ee4050751064 +Subproject commit 9f9237ab8a530eeff389161202bbc7283ad6af3e diff --git a/modules/python/README.md b/modules/python/README.md index 6860f2b..0cd676b 100644 --- a/modules/python/README.md +++ b/modules/python/README.md @@ -8,11 +8,15 @@ Settings This module supports virtual environments from conda and virtualenvwrapper. By default, only virtualenvwrapper is enabled. To disable virtualenvwrapper, add the following to *zpreztorc*. - zstyle ':prezto:module:python' skip-virtualenvwrapper-init 'on' +```sh +zstyle ':prezto:module:python' skip-virtualenvwrapper-init 'on' +``` Conda support is enabled by adding the following to *zpreztorc*. - zstyle ':prezto:module:python' conda-init 'on' +```sh +zstyle ':prezto:module:python' conda-init 'on' +``` Caution: using conda and virtualenvwrapper at the same time may cause conflicts. @@ -106,10 +110,18 @@ zstyle ':prezto:module:python:virtualenv' auto-switch 'yes' (`$VIRTUALENVWRAPPER_VIRTUALENV` is explicitly set or `virtualenv` is in `$PATH`). This can be disabled with: -``` +```sh zstyle ':prezto:module:python:virtualenv' initialize 'no' ``` +On some systems, the `python` binary doesn't exist so in order to get +virtualenvwrapper to work, the path needs to specified. We do our best to detect +this, but sometimes it needs manual intervention. + +```sh +zstyle ':prezto:module:python:virtualenvwrapper' python-path /opt/python3/bin/python3 +``` + Aliases ------- diff --git a/modules/python/init.zsh b/modules/python/init.zsh index 0d15fc0..365efc4 100644 --- a/modules/python/init.zsh +++ b/modules/python/init.zsh @@ -114,6 +114,20 @@ if (( $+VIRTUALENVWRAPPER_VIRTUALENV || $+commands[virtualenv] )) && \ else # Fallback to 'virtualenvwrapper' without 'pyenv' wrapper if available # in '$path' or in an alternative location on a Debian based system. + # + # If the python-path was manually specified, use that. Otherwise, fall back + # to python3 then python2 in that order. This is needed to fix an issue with + # virtualenvwrapper when used with homebrew, as it no longer shadows the + # system python. + zstyle -s ':prezto:module:python:virtualenvwrapper' python-path '_venv_python' + if [[ -n "$_venv_python" ]]; then + export VIRTUALENVWRAPPER_PYTHON=$_venv_python + elif (( $+commands[python3] )); then + export VIRTUALENVWRAPPER_PYTHON=$commands[python3] + elif (( $+commands[python2] )); then + export VIRTUALENVWRAPPER_PYTHON=$commands[python2] + fi + virtenv_sources=( ${(@Ov)commands[(I)virtualenvwrapper(_lazy|).sh]} /usr/share/virtualenvwrapper/virtualenvwrapper(_lazy|).sh(OnN)