8 Commits

Author SHA1 Message Date
Yamashita Yuu
32e5a73345 v20150119 2015-01-19 00:53:19 +09:00
Yamashita Yuu
0fc9441f09 Anaconda has activate script nevertheless it is not a virtual environment (#65) 2015-01-18 20:15:44 +09:00
Yamashita, Yuu
0fe9aef635 Merge pull request #64 from wwwjfy/master
fix wrong output in test in fish, refs 240a1de
2015-01-06 14:05:52 +09:00
Tony Wang
e04a6f88fe fix wrong output in test in fish, refs 240a1de
"(any command)" is not supported in test in fish, we have to set a
variable and then use that
2015-01-06 11:10:43 +08:00
Yamashita, Yuu
08c2e6aee4 Merge pull request #63 from wwwjfy/master
fix warns for virtualenv-init corner case on fish
2015-01-06 10:20:53 +09:00
Tony Wang
cc7c9d22b5 fix failed tests running under fish 2015-01-05 23:28:14 +08:00
Tony Wang
240a1de6e5 fix warns for virtualenv-init corner case on fish
The situation is when in a directory containing python binary,
`pyenv prefix' will return empty (caused by `pyenv which' returning
"./python"). This change adds quotes for `test', otherwise `test' will
warn about missing argument.
2015-01-05 23:23:43 +08:00
Yamashita Yuu
9d71e67401 Merge branch 'issue61' 2014-12-28 18:50:25 +09:00
7 changed files with 68 additions and 12 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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" {