mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-21 09:32:58 -05:00
Support free-threaded CPython flavor in prefix resolution (#3090)
Since 3.13, CPython is provided in 2 flavors: regular and free-threaded, with the 't' suffix. An incomplete prefix ending with '[0-9]t' resolves only among versions that also end with '[0-9]t'
This commit is contained in:
parent
03b60aafec
commit
3ced1c4751
2 changed files with 27 additions and 3 deletions
|
@ -48,16 +48,25 @@ IFS=$'\n'
|
|||
exit $exitcode;
|
||||
fi
|
||||
|
||||
suffix=""
|
||||
if [[ $prefix =~ ^(.*[0-9])t$ ]]; then
|
||||
suffix="t"
|
||||
prefix="${BASH_REMATCH[1]}"
|
||||
fi
|
||||
|
||||
# https://stackoverflow.com/questions/11856054/is-there-an-easy-way-to-pass-a-raw-string-to-grep/63483807#63483807
|
||||
prefix_re="$(sed 's/[^\^]/[&]/g;s/[\^]/\\&/g' <<< "$prefix")"
|
||||
suffix_re="$(sed 's/[^\^]/[&]/g;s/[\^]/\\&/g' <<< "$suffix")"
|
||||
# FIXME: more reliable and readable would probably be to loop over them and transform in pure Bash
|
||||
DEFINITION_CANDIDATES=(\
|
||||
$(printf '%s\n' "${DEFINITION_CANDIDATES[@]}" | \
|
||||
grep -Ee "^$prefix_re[-.]" || true))
|
||||
grep -Ee "^$prefix_re[-.].*$suffix_re\$" || true))
|
||||
|
||||
DEFINITION_CANDIDATES=(\
|
||||
$(printf '%s\n' "${DEFINITION_CANDIDATES[@]}" | \
|
||||
sed -E -e '/-dev$/d' -e '/-src$/d' -e '/-latest$/d' -e '/(a|b|rc)[0-9]+$/d' -e '/[0-9]+t$/d'));
|
||||
sed -E -e '/-dev$/d' -e '/-src$/d' -e '/-latest$/d' -e '/(a|b|rc)[0-9]+$/d' \
|
||||
$(if [[ -z $suffix ]]; then echo "-e /[0-9]t\$/d"; fi)
|
||||
));
|
||||
|
||||
# Compose a sorting key, followed by | and original value
|
||||
DEFINITION_CANDIDATES=(\
|
||||
|
|
|
@ -94,7 +94,7 @@ echo 3.10.6
|
|||
!
|
||||
}
|
||||
|
||||
@test "ignores rolling releases, branch tips, alternative srcs, prereleases and virtualenvs" {
|
||||
@test "ignores rolling releases, branch tips, alternative srcs, prereleases, virtualenvs; 't' versions if prefix without 't'" {
|
||||
create_executable pyenv-versions <<!
|
||||
#!$BASH
|
||||
echo 3.8.5-dev
|
||||
|
@ -116,6 +116,21 @@ echo 3.8.1/envs/foo
|
|||
!
|
||||
}
|
||||
|
||||
@test "resolves to a 't' version if prefix has 't'" {
|
||||
create_executable pyenv-versions <<!
|
||||
#!$BASH
|
||||
echo 3.13.2t
|
||||
echo 3.13.5
|
||||
echo 3.13.5t
|
||||
echo 3.14.6
|
||||
!
|
||||
run pyenv-latest 3t
|
||||
assert_success
|
||||
assert_output <<!
|
||||
3.13.5t
|
||||
!
|
||||
}
|
||||
|
||||
@test "falls back to argument with -b" {
|
||||
create_executable pyenv-versions <<!
|
||||
#!$BASH
|
||||
|
|
Loading…
Reference in a new issue