From ce6f7886758467a771cd6788d73cdea767ca8399 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Sun, 29 Jan 2023 23:19:25 +0300 Subject: [PATCH] Resolve the proper base version name --- bin/pyenv-virtualenv | 4 ++++ test/virtualenv.bats | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index 27f8d61..1d93c84 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -310,6 +310,10 @@ else VIRTUALENV_NAME="${ARGUMENTS[1]}" fi +if [[ -n "${VERSION_NAME}" ]] && command -v pyenv-latest >/dev/null; then + VERSION_NAME="$(pyenv-latest -q "${VERSION_NAME}" || echo "${VERSION_NAME}")" +fi + if [ -z "${VERSION_NAME}" ] || [ -z "${VIRTUALENV_NAME}" ]; then usage 1 fi diff --git a/test/virtualenv.bats b/test/virtualenv.bats index 0b6b562..26e9eb0 100644 --- a/test/virtualenv.bats +++ b/test/virtualenv.bats @@ -50,6 +50,35 @@ OUT unstub curl } +@test "create virtualenv from a given prefix" { + stub_pyenv "2.7.11" + stub pyenv-virtualenv-prefix " : false" + stub pyenv-exec "python2.7 -m venv --help : false" + stub pyenv-exec "python2 -m venv --help : false" + stub pyenv-exec "python -m venv --help : false" + stub pyenv-exec "virtualenv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\"" + stub pyenv-exec "python -s -m ensurepip : false" + stub pyenv-exec "python -s */get-pip.py : true" + stub curl true + stub pyenv-latest "2.7 : 2.7.11" + + run pyenv-virtualenv "2.7" "venv" + + assert_output <