ensure-python: Skip "t" versions in pyenv

The recent addition of "t" version variants in CPython 3.13 has
broken the ability of jobs to assume a normal executable name.

Change-Id: Ia27bdd4e122980f65c1bb9fc28fedf43c48a5a4e
This commit is contained in:
Jeremy Stanley 2025-01-24 17:04:40 +00:00
parent 16536f6746
commit b95cfa4ad7
2 changed files with 8 additions and 3 deletions

View File

@ -25,8 +25,10 @@ There are three ways to install the python interpreter:
:type: str
Optional version of python interpreter to install, such as ``3.7``.
Note that you should use a string value for this variable rather than
a float. This avoids problems with 3.10 being evaluated as 3.1.
Note that you should use a string value for this variable rather than a
float. This avoids problems with 3.10 being evaluated as 3.1. With the
pyenv backend it's not currently possible to select special-purpose
builds like the free-threading (no-GIL) variants.
.. zuul:rolevar:: python_use_pyenv
:type: bool

View File

@ -28,10 +28,13 @@
# NOTE(mnaser): python-build does not allow us to let it install Python from a specific
# series so we have to do some magic to find out what's the latest
# release from a series
# NOTE(fungi): due to https://github.com/pyenv/pyenv/issues/3015 we need to
# filter out no-GIL/free-threading "t" suffixed versions, since
# they don't provide the expected vanilla executables
- name: Determine Python version
shell: |
set -o pipefail
{{ ansible_user_dir }}/.pyenv/plugins/python-build/bin/python-build --definitions | grep ^{{ python_version }} | tail -1
{{ ansible_user_dir }}/.pyenv/plugins/python-build/bin/python-build --definitions | grep ^{{ python_version }} | grep -v t$ | tail -1
args:
executable: /bin/bash
register: _python_version