mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32e5a73345 | ||
|
|
0fc9441f09 | ||
|
|
0fe9aef635 | ||
|
|
e04a6f88fe | ||
|
|
08c2e6aee4 | ||
|
|
cc7c9d22b5 | ||
|
|
240a1de6e5 | ||
|
|
9d71e67401 |
@@ -157,6 +157,12 @@ You can set certain environment variables to control pyenv-virtualenv.
|
||||
|
||||
## Version History
|
||||
|
||||
#### 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
|
||||
|
||||
* Stop creating after `ensurepip` since it has done by `ensurepip` itself
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# -f/--force Install even if the version appears to be installed already
|
||||
#
|
||||
|
||||
PYENV_VIRTUALENV_VERSION="20141106"
|
||||
PYENV_VIRTUALENV_VERSION="20150119"
|
||||
|
||||
set -e
|
||||
[ -n "$PYENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -75,13 +75,14 @@ case "$shell" in
|
||||
fish )
|
||||
cat <<EOS
|
||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
set -l PYENV_PREFIX (pyenv prefix 2>/dev/null; or true)
|
||||
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
|
||||
set -e PYENV_DEACTIVATE
|
||||
return 0
|
||||
end
|
||||
if [ "\$PYENV_ACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
||||
if [ "\$PYENV_ACTIVATE" != "\$PYENV_PREFIX" ]
|
||||
if pyenv deactivate --no-error --verbose
|
||||
set -e PYENV_DEACTIVATE
|
||||
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
||||
@@ -90,7 +91,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
end
|
||||
end
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,8 +38,14 @@ for version in "${versions[@]}"; do
|
||||
fi
|
||||
PREFIX="$(pyenv-prefix "${version}")"
|
||||
if [ -f "${PREFIX}/bin/activate" ]; then
|
||||
VIRTUALENV_PREFIX_PATH="$(real_prefix "${version}" || base_prefix "${version}" || true)"
|
||||
VIRTUALENV_PREFIX_PATHS=("${VIRTUALENV_PREFIX_PATHS[@]}" "$VIRTUALENV_PREFIX_PATH")
|
||||
# Anaconda has `activate` script nevertheless it is not a virtual environment (#65)
|
||||
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
|
||||
echo "pyenv-virtualenv: version \`${version}' is not a virtualenv" 1>&2
|
||||
exit 1
|
||||
|
||||
@@ -123,7 +123,7 @@ EOS
|
||||
stub pyenv-virtualenv-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
|
||||
@@ -144,7 +144,7 @@ EOS
|
||||
stub pyenv-virtualenv-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
|
||||
@@ -159,6 +159,48 @@ export PYENV_ACTIVATE="${PYENV_ROOT}/versions/venv27";
|
||||
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-prefix
|
||||
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
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
|
||||
}
|
||||
|
||||
@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
|
||||
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
|
||||
}
|
||||
|
||||
@test "unset invokes deactivate" {
|
||||
run pyenv-sh-activate --unset
|
||||
|
||||
|
||||
@@ -63,13 +63,14 @@ EOS
|
||||
assert_output <<EOS
|
||||
setenv PYENV_VIRTUALENV_INIT 1;
|
||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
set -l PYENV_PREFIX (pyenv prefix 2>/dev/null; or true)
|
||||
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
|
||||
set -e PYENV_DEACTIVATE
|
||||
return 0
|
||||
end
|
||||
if [ "\$PYENV_ACTIVATE" != (pyenv prefix 2>/dev/null; or true) ]
|
||||
if [ "\$PYENV_ACTIVATE" != "\$PYENV_PREFIX" ]
|
||||
if pyenv deactivate --no-error --verbose
|
||||
set -e PYENV_DEACTIVATE
|
||||
pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE
|
||||
@@ -78,7 +79,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||
end
|
||||
end
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ load test_helper
|
||||
|
||||
setup() {
|
||||
export PYENV_ROOT="${TMP}/pyenv"
|
||||
export PYENV_VIRTUALENV_VERSION="20141106"
|
||||
export PYENV_VIRTUALENV_VERSION="20150119"
|
||||
}
|
||||
|
||||
@test "display virtualenv version" {
|
||||
|
||||
Reference in New Issue
Block a user