mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-11 13:03:52 -05:00
More helpful error message when env's base version is not installed (#454)
This commit is contained in:
committed by
GitHub
parent
fca12418ca
commit
85d8c5aabf
@@ -336,10 +336,20 @@ 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}"
|
||||||
|
|
||||||
|
not_installed_message() {
|
||||||
|
local is_available=$(python-build --definitions | grep -F -x "$1")
|
||||||
|
echo "pyenv-virtualenv: \`${1}' is not installed in pyenv." 1>&2
|
||||||
|
if [[ $is_available ]]; then
|
||||||
|
echo "Run \`pyenv install ${1}' to install it." 1>&2
|
||||||
|
else
|
||||||
|
echo "It does not look like a valid Python version. See \`pyenv install --list' for available versions." 1>&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Source version must exist before creating virtualenv.
|
# Source version must exist before creating virtualenv.
|
||||||
PREFIX="$(pyenv-prefix 2>/dev/null || true)"
|
PREFIX="$(pyenv-prefix 2>/dev/null || true)"
|
||||||
if [ ! -d "${PREFIX}" ]; then
|
if [ ! -d "${PREFIX}" ]; then
|
||||||
echo "pyenv-virtualenv: \`${PYENV_VERSION}' is not installed in pyenv." 1>&2
|
not_installed_message "${PYENV_VERSION}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -441,7 +451,8 @@ else
|
|||||||
if [ -x "${python}" ]; then
|
if [ -x "${python}" ]; then
|
||||||
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--python=${python}"
|
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--python=${python}"
|
||||||
else
|
else
|
||||||
echo "pyenv-virtualenv: \`${VIRTUALENV_PYTHON##*/}' is not installed in pyenv." 1>&2
|
# echo "pyenv-virtualenv: \`${VIRTUALENV_PYTHON##*/}' is not installed in pyenv." 1>&2
|
||||||
|
not_installed_message "${VIRTUALENV_PYTHON##*/}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ setup() {
|
|||||||
stub pyenv-rehash " : true"
|
stub pyenv-rehash " : true"
|
||||||
stub pyenv-version-name "echo \${PYENV_VERSION}"
|
stub pyenv-version-name "echo \${PYENV_VERSION}"
|
||||||
stub curl true
|
stub curl true
|
||||||
|
stub python-build "echo python2.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
@@ -22,6 +23,7 @@ teardown() {
|
|||||||
unstub pyenv-prefix
|
unstub pyenv-prefix
|
||||||
unstub pyenv-hooks
|
unstub pyenv-hooks
|
||||||
unstub pyenv-rehash
|
unstub pyenv-rehash
|
||||||
|
unstub python-build
|
||||||
teardown_version "2.7.8"
|
teardown_version "2.7.8"
|
||||||
rm -fr "$TMP"/*
|
rm -fr "$TMP"/*
|
||||||
}
|
}
|
||||||
@@ -96,6 +98,7 @@ OUT
|
|||||||
|
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
pyenv-virtualenv: \`python2.7' is not installed in pyenv.
|
pyenv-virtualenv: \`python2.7' is not installed in pyenv.
|
||||||
|
Run \`pyenv install python2.7' to install it.
|
||||||
OUT
|
OUT
|
||||||
assert_failure
|
assert_failure
|
||||||
|
|
||||||
@@ -106,3 +109,13 @@ OUT
|
|||||||
remove_executable "2.7.8" "python2.7"
|
remove_executable "2.7.8" "python2.7"
|
||||||
remove_executable "2.7.9" "python2.7"
|
remove_executable "2.7.9" "python2.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "invalid python name" {
|
||||||
|
run pyenv-virtualenv --verbose --python=99.99.99 venv
|
||||||
|
|
||||||
|
assert_output <<OUT
|
||||||
|
pyenv-virtualenv: \`99.99.99' is not installed in pyenv.
|
||||||
|
It does not look like a valid Python version. See \`pyenv install --list' for available versions.
|
||||||
|
OUT
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user