File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 336336# Set VERSION_NAME as default version in this script
337337export PYENV_VERSION=" ${VERSION_NAME} "
338338
339+ not_installed_message () {
340+ local is_available=$( python-build --definitions | grep -F -x " $1 " )
341+ echo " pyenv-virtualenv: \` ${1} ' is not installed in pyenv." 1>&2
342+ if [[ $is_available ]]; then
343+ echo " Run \` pyenv install ${1} ' to install it." 1>&2
344+ else
345+ echo " It does not look like a valid Python version. See \` pyenv install --list' for available versions." 1>&2
346+ fi
347+ }
348+
339349# Source version must exist before creating virtualenv.
340350PREFIX=" $( pyenv-prefix 2> /dev/null || true) "
341351if [ ! -d " ${PREFIX} " ]; then
342- echo " pyenv-virtualenv: \` ${PYENV_VERSION} ' is not installed in pyenv. " 1>&2
352+ not_installed_message " ${PYENV_VERSION} "
343353 exit 1
344354fi
345355
441451 if [ -x " ${python} " ]; then
442452 VIRTUALENV_OPTIONS[${# VIRTUALENV_OPTIONS[*]} ]=" --python=${python} "
443453 else
444- echo " pyenv-virtualenv: \` ${VIRTUALENV_PYTHON##*/ } ' is not installed in pyenv." 1>&2
454+ # echo "pyenv-virtualenv: \`${VIRTUALENV_PYTHON##*/}' is not installed in pyenv." 1>&2
455+ not_installed_message " ${VIRTUALENV_PYTHON##*/ } "
445456 exit 1
446457 fi
447458 fi
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ setup() {
1414 stub pyenv-rehash " : true"
1515 stub pyenv-version-name " echo \$ {PYENV_VERSION}"
1616 stub curl true
17+ stub python-build " echo python2.7"
1718}
1819
1920teardown () {
@@ -22,6 +23,7 @@ teardown() {
2223 unstub pyenv-prefix
2324 unstub pyenv-hooks
2425 unstub pyenv-rehash
26+ unstub python-build
2527 teardown_version " 2.7.8"
2628 rm -fr " $TMP " /*
2729}
9698
9799 assert_output << OUT
98100pyenv-virtualenv: \` python2.7' is not installed in pyenv.
101+ Run \` pyenv install python2.7' to install it.
99102OUT
100103 assert_failure
101104
106109 remove_executable " 2.7.8" " python2.7"
107110 remove_executable " 2.7.9" " python2.7"
108111}
112+
113+ @test " invalid python name" {
114+ run pyenv-virtualenv --verbose --python=99.99.99 venv
115+
116+ assert_output << OUT
117+ pyenv-virtualenv: \` 99.99.99' is not installed in pyenv.
118+ It does not look like a valid Python version. See \` pyenv install --list' for available versions.
119+ OUT
120+ assert_failure
121+ }
You can’t perform that action at this time.
0 commit comments