浏览代码

More helpful error message when env's base version is not installed (#454)

pull/457/head
Marcin Konowalczyk 1年前
提交者 GitHub
父节点
当前提交
85d8c5aabf
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 2 个文件被更改,包括 26 次插入2 次删除
  1. +13
    -2
      bin/pyenv-virtualenv
  2. +13
    -0
      test/python.bats

+ 13
- 2
bin/pyenv-virtualenv 查看文件

@ -336,10 +336,20 @@ fi
# Set VERSION_NAME as default version in this script
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.
PREFIX="$(pyenv-prefix 2>/dev/null || true)"
if [ ! -d "${PREFIX}" ]; then
echo "pyenv-virtualenv: \`${PYENV_VERSION}' is not installed in pyenv." 1>&2
not_installed_message "${PYENV_VERSION}"
exit 1
fi
@ -441,7 +451,8 @@ else
if [ -x "${python}" ]; then
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--python=${python}"
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
fi
fi

+ 13
- 0
test/python.bats 查看文件

@ -14,6 +14,7 @@ setup() {
stub pyenv-rehash " : true"
stub pyenv-version-name "echo \${PYENV_VERSION}"
stub curl true
stub python-build "echo python2.7"
}
teardown() {
@ -22,6 +23,7 @@ teardown() {
unstub pyenv-prefix
unstub pyenv-hooks
unstub pyenv-rehash
unstub python-build
teardown_version "2.7.8"
rm -fr "$TMP"/*
}
@ -96,6 +98,7 @@ OUT
assert_output <<OUT
pyenv-virtualenv: \`python2.7' is not installed in pyenv.
Run \`pyenv install python2.7' to install it.
OUT
assert_failure
@ -106,3 +109,13 @@ OUT
remove_executable "2.7.8" "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
}

正在加载...
取消
保存