mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-09 03:53:54 -05:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a52f9fb5d | ||
|
|
0ca01826e8 | ||
|
|
4fa9c7b220 | ||
|
|
2571a2b973 | ||
|
|
95fa7a35ad | ||
|
|
47cd86a165 | ||
|
|
d9c3f9a2f5 | ||
|
|
6bc0253d17 | ||
|
|
c184c01174 | ||
|
|
55189357e2 | ||
|
|
9544c8b178 | ||
|
|
bcb7abdf93 | ||
|
|
5953ddaf64 | ||
|
|
2ab9483116 | ||
|
|
32e5a73345 | ||
|
|
0fc9441f09 | ||
|
|
0fe9aef635 | ||
|
|
e04a6f88fe | ||
|
|
08c2e6aee4 | ||
|
|
cc7c9d22b5 | ||
|
|
240a1de6e5 | ||
|
|
9d71e67401 |
15
README.md
15
README.md
@@ -125,11 +125,10 @@ You can also activate and deactivate a pyenv virtualenv manually:
|
|||||||
Removing the directory in `~/.pyenv/versions` will delete the virtualenv, or you can run:
|
Removing the directory in `~/.pyenv/versions` will delete the virtualenv, or you can run:
|
||||||
|
|
||||||
pyenv uninstall my-virtual-env
|
pyenv uninstall my-virtual-env
|
||||||
|
|
||||||
|
|
||||||
### virtualenv and pyvenv
|
### virtualenv and pyvenv
|
||||||
|
|
||||||
There is a [venv](http://docs.python.jp/3/library/venv.html) module available
|
There is a [venv](http://docs.python.org/3/library/venv.html) module available
|
||||||
for CPython 3.3 and newer.
|
for CPython 3.3 and newer.
|
||||||
It provides a command-line tool `pyvenv` which is the successor of `virtualenv`
|
It provides a command-line tool `pyvenv` which is the successor of `virtualenv`
|
||||||
and distributed by default.
|
and distributed by default.
|
||||||
@@ -157,6 +156,18 @@ You can set certain environment variables to control pyenv-virtualenv.
|
|||||||
|
|
||||||
## Version History
|
## Version History
|
||||||
|
|
||||||
|
#### 20150526
|
||||||
|
|
||||||
|
* Use `typeset -g` with `precmd_functions` (#75)
|
||||||
|
* activate: display setup instructions only with `PYENV_VIRTUALENV_INIT=0` (#78)
|
||||||
|
* Ignore failure of pyenv activate (#68)
|
||||||
|
|
||||||
|
#### 20150119
|
||||||
|
|
||||||
|
* Ignore errors from `pyenv-version-name` since it might fail if there is configuration error (yyuu/pyenv#291)
|
||||||
|
* The _shell_ version set in `activate` should be unset in `deactivate` (#61)
|
||||||
|
* Anaconda has `activate` script nevertheless it is not a virtual environment (#65)
|
||||||
|
|
||||||
#### 20141106
|
#### 20141106
|
||||||
|
|
||||||
* Stop creating after `ensurepip` since it has done by `ensurepip` itself
|
* Stop creating after `ensurepip` since it has done by `ensurepip` itself
|
||||||
|
|||||||
@@ -68,27 +68,11 @@ if ! pyenv-virtualenv-prefix "${versions}" 1>/dev/null 2>&1; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
|
shell="${PYENV_SHELL:-${SHELL##*/}}"
|
||||||
case "$shell" in
|
|
||||||
bash )
|
|
||||||
profile="$HOME/.bash_profile"
|
|
||||||
;;
|
|
||||||
zsh )
|
|
||||||
profile="$HOME/.zshrc"
|
|
||||||
;;
|
|
||||||
ksh )
|
|
||||||
profile="$HOME/.profile"
|
|
||||||
;;
|
|
||||||
fish )
|
|
||||||
profile="$HOME/.config/fish/config.fish"
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
profile="$HOME/.profile"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Display setup instruction if 'pyenv virtualenv-init -' is not found in "$profile"
|
# Display setup instruction, if pyenv-virtualenv has not been initialized.
|
||||||
if [ -f "$profile" ] && grep -q 'pyenv init -' "$profile" && ! grep -q 'pyenv virtualenv-init -' "$profile"; then
|
# if 'pyenv virtualenv-init -' is not found in "$profile"
|
||||||
|
if [ -z "$PYENV_VIRTUALENV_INIT" ]; then
|
||||||
pyenv-virtualenv-init >&2 || true
|
pyenv-virtualenv-init >&2 || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
#
|
#
|
||||||
# Summary: Create a Python virtualenv using the pyenv-virtualenv plugin
|
# Summary: Create a Python virtualenv using the pyenv-virtualenv plugin
|
||||||
#
|
#
|
||||||
# Usage: pyenv virtualenv [-f|--force] [VIRTUALENV_OPTIONS] <version> <virtualenv-name>
|
# Usage: pyenv virtualenv [-f|--force] [VIRTUALENV_OPTIONS] [version] <virtualenv-name>
|
||||||
# pyenv virtualenv --version
|
# pyenv virtualenv --version
|
||||||
# pyenv virtualenv --help
|
# pyenv virtualenv --help
|
||||||
#
|
#
|
||||||
# -f/--force Install even if the version appears to be installed already
|
# -f/--force Install even if the version appears to be installed already
|
||||||
#
|
#
|
||||||
|
|
||||||
PYENV_VIRTUALENV_VERSION="20141106"
|
PYENV_VIRTUALENV_VERSION="20150526"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
@@ -283,7 +283,7 @@ fi
|
|||||||
# Set VERSION_NAME as default version in this script
|
# Set VERSION_NAME as default version in this script
|
||||||
export PYENV_VERSION="${VERSION_NAME}"
|
export PYENV_VERSION="${VERSION_NAME}"
|
||||||
|
|
||||||
# Source version must exists before creating virtualenv
|
# Source version must exist before creating virtualenv.
|
||||||
pyenv-prefix 1>/dev/null 2>&1 || usage 1
|
pyenv-prefix 1>/dev/null 2>&1 || usage 1
|
||||||
|
|
||||||
if [ -z "$TMPDIR" ]; then
|
if [ -z "$TMPDIR" ]; then
|
||||||
@@ -328,12 +328,12 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unset environment variables which starts with `VIRTUALENV_`.
|
# Unset environment variables which start with `VIRTUALENV_`.
|
||||||
# These variables are reserved for virtualenv.
|
# These variables are reserved for virtualenv.
|
||||||
unset VIRTUALENV_VERSION
|
unset VIRTUALENV_VERSION
|
||||||
|
|
||||||
|
|
||||||
# Download specified version of ez_setup.py/get-pip.py
|
# Download specified version of ez_setup.py/get-pip.py.
|
||||||
if [ -n "${SETUPTOOLS_VERSION}" ]; then
|
if [ -n "${SETUPTOOLS_VERSION}" ]; then
|
||||||
EZ_SETUP_URL="https://bitbucket.org/pypa/setuptools/raw/${SETUPTOOLS_VERSION}/ez_setup.py"
|
EZ_SETUP_URL="https://bitbucket.org/pypa/setuptools/raw/${SETUPTOOLS_VERSION}/ez_setup.py"
|
||||||
fi
|
fi
|
||||||
@@ -396,19 +396,19 @@ trap cleanup SIGINT
|
|||||||
|
|
||||||
# Invoke virtualenv and record exit status in $STATUS.
|
# Invoke virtualenv and record exit status in $STATUS.
|
||||||
STATUS=0
|
STATUS=0
|
||||||
# virtualenv may download distribute/setuptools in current directory.
|
# virtualenv may download distribute/setuptools into the current directory.
|
||||||
# change to cache directory to reuse them between invocation.
|
# Change to cache directory to reuse them between invocations.
|
||||||
mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}"
|
mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}"
|
||||||
cd "${PYENV_VIRTUALENV_CACHE_PATH}"
|
cd "${PYENV_VIRTUALENV_CACHE_PATH}"
|
||||||
venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"
|
venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"
|
||||||
|
|
||||||
## Install setuptools and pip
|
## Install setuptools and pip.
|
||||||
PYENV_VERSION="${VIRTUALENV_NAME}" build_package_ensurepip
|
PYENV_VERSION="${VIRTUALENV_NAME}" build_package_ensurepip
|
||||||
|
|
||||||
## Migrate previously installed packages from requirements.txt
|
## Migrate previously installed packages from requirements.txt.
|
||||||
PYENV_VERSION="${VIRTUALENV_NAME}" install_requirements || true
|
PYENV_VERSION="${VIRTUALENV_NAME}" install_requirements || true
|
||||||
|
|
||||||
# Execute `after_virtualenv` hooks
|
# Execute `after_virtualenv` hooks.
|
||||||
for hook in "${after_hooks[@]}"; do eval "$hook"; done
|
for hook in "${after_hooks[@]}"; do eval "$hook"; done
|
||||||
|
|
||||||
# Run `pyenv-rehash` after a successful installation.
|
# Run `pyenv-rehash` after a successful installation.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
shell="$1"
|
shell="${1:-$PYENV_SHELL}"
|
||||||
if [ -z "$shell" ]; then
|
if [ -z "$shell" ]; then
|
||||||
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
|
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
|
||||||
shell="${shell##-}"
|
shell="${shell##-}"
|
||||||
@@ -75,13 +75,14 @@ case "$shell" in
|
|||||||
fish )
|
fish )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||||
|
set -l PYENV_PREFIX (pyenv prefix 2>/dev/null; or true)
|
||||||
if [ -n "\$PYENV_ACTIVATE" ]
|
if [ -n "\$PYENV_ACTIVATE" ]
|
||||||
if [ (pyenv version-name 2>/dev/null; or true) = "system" ]
|
if [ "(pyenv version-name 2>/dev/null; or true)" = "system" ]
|
||||||
pyenv deactivate --no-error --verbose
|
pyenv deactivate --no-error --verbose
|
||||||
set -e PYENV_DEACTIVATE
|
set -e PYENV_DEACTIVATE
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if [ "\$PYENV_ACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
if [ "\$PYENV_ACTIVATE" != "\$PYENV_PREFIX" ]
|
||||||
if pyenv deactivate --no-error --verbose
|
if pyenv deactivate --no-error --verbose
|
||||||
set -e PYENV_DEACTIVATE
|
set -e PYENV_DEACTIVATE
|
||||||
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
||||||
@@ -90,8 +91,8 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != "\$PYENV_PREFIX" ]
|
||||||
pyenv activate --no-error --verbose
|
pyenv activate --no-error --verbose; or true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -127,7 +128,7 @@ if [[ "$shell" != "fish" ]]; then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
||||||
pyenv activate --no-error --verbose
|
pyenv activate --no-error --verbose || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
};
|
};
|
||||||
@@ -143,7 +144,7 @@ EOS
|
|||||||
;;
|
;;
|
||||||
zsh )
|
zsh )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
typeset -a precmd_functions
|
typeset -g -a precmd_functions
|
||||||
if [[ -z \$precmd_functions[(r)_pyenv_virtualenv_hook] ]]; then
|
if [[ -z \$precmd_functions[(r)_pyenv_virtualenv_hook] ]]; then
|
||||||
precmd_functions+=_pyenv_virtualenv_hook;
|
precmd_functions+=_pyenv_virtualenv_hook;
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -38,8 +38,14 @@ for version in "${versions[@]}"; do
|
|||||||
fi
|
fi
|
||||||
PREFIX="$(pyenv-prefix "${version}")"
|
PREFIX="$(pyenv-prefix "${version}")"
|
||||||
if [ -f "${PREFIX}/bin/activate" ]; then
|
if [ -f "${PREFIX}/bin/activate" ]; then
|
||||||
VIRTUALENV_PREFIX_PATH="$(real_prefix "${version}" || base_prefix "${version}" || true)"
|
# Anaconda has `activate` script nevertheless it is not a virtual environment (#65)
|
||||||
VIRTUALENV_PREFIX_PATHS=("${VIRTUALENV_PREFIX_PATHS[@]}" "$VIRTUALENV_PREFIX_PATH")
|
if [ -f "${PREFIX}/bin/conda" ]; then
|
||||||
|
echo "pyenv-virtualenv: version \`${version}' is an anaconda/miniconda" 1>&2
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
VIRTUALENV_PREFIX_PATH="$(real_prefix "${version}" || base_prefix "${version}" || true)"
|
||||||
|
VIRTUALENV_PREFIX_PATHS=("${VIRTUALENV_PREFIX_PATHS[@]}" "$VIRTUALENV_PREFIX_PATH")
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "pyenv-virtualenv: version \`${version}' is not a virtualenv" 1>&2
|
echo "pyenv-virtualenv: version \`${version}' is not a virtualenv" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ EOS
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
|
# Load pyenv-virtualenv automatically by adding
|
||||||
|
# the following to ~/.bash_profile:
|
||||||
|
|
||||||
|
eval "\$(pyenv virtualenv-init -)"
|
||||||
|
|
||||||
pyenv shell "venv";
|
pyenv shell "venv";
|
||||||
export PYENV_ACTIVATE_SHELL=1;
|
export PYENV_ACTIVATE_SHELL=1;
|
||||||
unset PYENV_DEACTIVATE;
|
unset PYENV_DEACTIVATE;
|
||||||
@@ -109,6 +114,11 @@ EOS
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
|
# Load pyenv-virtualenv automatically by adding
|
||||||
|
# the following to ~/.config/fish/config.fish:
|
||||||
|
|
||||||
|
status --is-interactive; and . (pyenv virtualenv-init -|psub)
|
||||||
|
|
||||||
pyenv shell "venv";
|
pyenv shell "venv";
|
||||||
setenv PYENV_ACTIVATE_SHELL 1;
|
setenv PYENV_ACTIVATE_SHELL 1;
|
||||||
set -e PYENV_DEACTIVATE;
|
set -e PYENV_DEACTIVATE;
|
||||||
@@ -123,7 +133,7 @@ EOS
|
|||||||
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
|
||||||
run pyenv-sh-activate "venv27"
|
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate "venv27"
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
unstub pyenv-prefix
|
unstub pyenv-prefix
|
||||||
@@ -144,7 +154,33 @@ EOS
|
|||||||
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
|
||||||
run pyenv-sh-activate "venv27"
|
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate "venv27"
|
||||||
|
|
||||||
|
unstub pyenv-virtualenv-prefix
|
||||||
|
unstub pyenv-prefix
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
# Load pyenv-virtualenv automatically by adding
|
||||||
|
# the following to ~/.bash_profile:
|
||||||
|
|
||||||
|
eval "\$(pyenv virtualenv-init -)"
|
||||||
|
|
||||||
|
pyenv shell "venv27";
|
||||||
|
export PYENV_ACTIVATE_SHELL=1;
|
||||||
|
unset PYENV_DEACTIVATE;
|
||||||
|
export PYENV_ACTIVATE="${PYENV_ROOT}/versions/venv27";
|
||||||
|
. "${PYENV_ROOT}/versions/venv27/bin/activate";
|
||||||
|
EOS
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "activate virtualenv from command-line argument (fish)" {
|
||||||
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
|
|
||||||
|
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
|
||||||
|
PYENV_SHELL="fish" PYENV_VERSION="venv" run pyenv-sh-activate "venv27"
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
unstub pyenv-prefix
|
unstub pyenv-prefix
|
||||||
@@ -152,10 +188,36 @@ EOS
|
|||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
pyenv shell "venv27";
|
pyenv shell "venv27";
|
||||||
export PYENV_ACTIVATE_SHELL=1;
|
setenv PYENV_ACTIVATE_SHELL 1;
|
||||||
unset PYENV_DEACTIVATE;
|
set -e PYENV_DEACTIVATE;
|
||||||
export PYENV_ACTIVATE="${PYENV_ROOT}/versions/venv27";
|
setenv PYENV_ACTIVATE "${PYENV_ROOT}/versions/venv27";
|
||||||
. "${PYENV_ROOT}/versions/venv27/bin/activate";
|
. "${PYENV_ROOT}/versions/venv27/bin/activate.fish";
|
||||||
|
EOS
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "activate virtualenv from command-line argument (fish) (without pyenv-virtualenv-init)" {
|
||||||
|
export PYENV_VIRTUALENV_INIT=
|
||||||
|
|
||||||
|
stub pyenv-virtualenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
stub pyenv-prefix "venv27 : echo \"${PYENV_ROOT}/versions/venv27\""
|
||||||
|
|
||||||
|
PYENV_SHELL="fish" PYENV_VERSION="venv" run pyenv-sh-activate "venv27"
|
||||||
|
|
||||||
|
unstub pyenv-virtualenv-prefix
|
||||||
|
unstub pyenv-prefix
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
# Load pyenv-virtualenv automatically by adding
|
||||||
|
# the following to ~/.config/fish/config.fish:
|
||||||
|
|
||||||
|
status --is-interactive; and . (pyenv virtualenv-init -|psub)
|
||||||
|
|
||||||
|
pyenv shell "venv27";
|
||||||
|
setenv PYENV_ACTIVATE_SHELL 1;
|
||||||
|
set -e PYENV_DEACTIVATE;
|
||||||
|
setenv PYENV_ACTIVATE "${PYENV_ROOT}/versions/venv27";
|
||||||
|
. "${PYENV_ROOT}/versions/venv27/bin/activate.fish";
|
||||||
EOS
|
EOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
@test "detect parent shell" {
|
@test "detect parent shell" {
|
||||||
|
unset PYENV_SHELL
|
||||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||||
SHELL=/bin/false run pyenv-virtualenv-init -
|
SHELL=/bin/false run pyenv-virtualenv-init -
|
||||||
assert_success
|
assert_success
|
||||||
@@ -47,7 +48,7 @@ _pyenv_virtualenv_hook() {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
||||||
pyenv activate --no-error --verbose
|
pyenv activate --no-error --verbose || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
};
|
};
|
||||||
@@ -63,13 +64,14 @@ EOS
|
|||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
setenv PYENV_VIRTUALENV_INIT 1;
|
setenv PYENV_VIRTUALENV_INIT 1;
|
||||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||||
|
set -l PYENV_PREFIX (pyenv prefix 2>/dev/null; or true)
|
||||||
if [ -n "\$PYENV_ACTIVATE" ]
|
if [ -n "\$PYENV_ACTIVATE" ]
|
||||||
if [ (pyenv version-name 2>/dev/null; or true) = "system" ]
|
if [ "(pyenv version-name 2>/dev/null; or true)" = "system" ]
|
||||||
pyenv deactivate --no-error --verbose
|
pyenv deactivate --no-error --verbose
|
||||||
set -e PYENV_DEACTIVATE
|
set -e PYENV_DEACTIVATE
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if [ "\$PYENV_ACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
if [ "\$PYENV_ACTIVATE" != "\$PYENV_PREFIX" ]
|
||||||
if pyenv deactivate --no-error --verbose
|
if pyenv deactivate --no-error --verbose
|
||||||
set -e PYENV_DEACTIVATE
|
set -e PYENV_DEACTIVATE
|
||||||
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
||||||
@@ -78,8 +80,8 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != "\$PYENV_PREFIX" ]
|
||||||
pyenv activate --no-error --verbose
|
pyenv activate --no-error --verbose; or true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -108,11 +110,11 @@ _pyenv_virtualenv_hook() {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then
|
||||||
pyenv activate --no-error --verbose
|
pyenv activate --no-error --verbose || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
};
|
};
|
||||||
typeset -a precmd_functions
|
typeset -g -a precmd_functions
|
||||||
if [[ -z \$precmd_functions[(r)_pyenv_virtualenv_hook] ]]; then
|
if [[ -z \$precmd_functions[(r)_pyenv_virtualenv_hook] ]]; then
|
||||||
precmd_functions+=_pyenv_virtualenv_hook;
|
precmd_functions+=_pyenv_virtualenv_hook;
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ load test_helper
|
|||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
export PYENV_ROOT="${TMP}/pyenv"
|
export PYENV_ROOT="${TMP}/pyenv"
|
||||||
export PYENV_VIRTUALENV_VERSION="20141106"
|
export PYENV_VIRTUALENV_VERSION="20150526"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "display virtualenv version" {
|
@test "display virtualenv version" {
|
||||||
|
|||||||
Reference in New Issue
Block a user