mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-14 20:39:55 -05:00
Fix latest version resolution when using python-
prefix (#3056)
Fixes use of version specifiers like `python-3.12`, which: - have an explicit `python-` prefix - are using a major version alias that has to be resolved to an exact version. Also simplified the conditional for the already working case, since it had two branches that were virtually identical.
This commit is contained in:
parent
1cabb6e02b
commit
d60d1c5cdc
2 changed files with 12 additions and 5 deletions
|
@ -30,11 +30,11 @@ OLDIFS="$IFS"
|
||||||
{ IFS=:
|
{ IFS=:
|
||||||
any_not_installed=0
|
any_not_installed=0
|
||||||
for version in ${PYENV_VERSION}; do
|
for version in ${PYENV_VERSION}; do
|
||||||
if version_exists "$version" || [ "$version" = "system" ]; then
|
# Remove the explicit 'python-' prefix from versions like 'python-3.12'.
|
||||||
versions=("${versions[@]}" "${version}")
|
normalised_version="${version#python-}"
|
||||||
elif version_exists "${version#python-}"; then
|
if version_exists "${normalised_version}" || [ "$version" = "system" ]; then
|
||||||
versions=("${versions[@]}" "${version#python-}")
|
versions=("${versions[@]}" "${normalised_version}")
|
||||||
elif resolved_version="$(pyenv-latest -b "$version")"; then
|
elif resolved_version="$(pyenv-latest -b "${normalised_version}")"; then
|
||||||
versions=("${versions[@]}" "${resolved_version}")
|
versions=("${versions[@]}" "${resolved_version}")
|
||||||
else
|
else
|
||||||
echo "pyenv: version \`$version' is not installed (set by $(pyenv-version-origin))" >&2
|
echo "pyenv: version \`$version' is not installed (set by $(pyenv-version-origin))" >&2
|
||||||
|
|
|
@ -120,3 +120,10 @@ OUT
|
||||||
assert_success
|
assert_success
|
||||||
assert_output "2.7.11"
|
assert_output "2.7.11"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "pyenv-latest fallback with prefix in name" {
|
||||||
|
create_version "3.12.6"
|
||||||
|
PYENV_VERSION="python-3.12" run pyenv-version-name
|
||||||
|
assert_success
|
||||||
|
assert_output "3.12.6"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue