Skip to content

Commit

Permalink
python: make a reasonable guess about virtualenvwrapper python location
Browse files Browse the repository at this point in the history
Fixes #1416
  • Loading branch information
belak committed Dec 11, 2017
1 parent aa03952 commit e021ade
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/autosuggestions/external
18 changes: 15 additions & 3 deletions modules/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
-------

Expand Down
14 changes: 14 additions & 0 deletions modules/python/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e021ade

Please sign in to comment.