From 0bdb14cc1d2e602ffe8c0830cc35d184e01741f6 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 3 Nov 2026 19:55:27 +0100 Subject: [PATCH] fix(dev-python): name the requires-python hand-over outside the .env key space #1347 passed the supported Python range to the remote install.sh as INFINITO_PYTHON_REQUIRES. Every INFINITO_* name is a key of the generated .env, so test_every_referenced_infinito_key_is_registered fails on main for this one, which no registry entry can carry: its value is derived from pyproject.toml's requires-python, the single source, and a default in default.env would be a second copy of the range. The task environment and the script now call it DEV_PYTHON_REQUIRES; behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 --- roles/dev-python/files/shell/install.sh | 6 +++--- roles/dev-python/tasks/00_core.yml | 2 +- tests/unit/python/roles/dev-python/files/test_install.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/dev-python/files/shell/install.sh b/roles/dev-python/files/shell/install.sh index e6796f1ee8..5255a2a02d 100755 --- a/roles/dev-python/files/shell/install.sh +++ b/roles/dev-python/files/shell/install.sh @@ -6,13 +6,13 @@ REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../.." && pwd)" DOCKER_APT_SANITIZER="${REPO_ROOT}/roles/sys-svc-container/files/shell/apt_repo.sh" python_requires_spec() { - if [[ -v INFINITO_PYTHON_REQUIRES ]]; then - printf '%s\n' "${INFINITO_PYTHON_REQUIRES}" + if [[ -v DEV_PYTHON_REQUIRES ]]; then + printf '%s\n' "${DEV_PYTHON_REQUIRES}" return 0 fi local pyproject="${REPO_ROOT}/pyproject.toml" if [[ ! -f "${pyproject}" ]]; then - echo "[ERROR] Neither INFINITO_PYTHON_REQUIRES nor ${pyproject} names the supported Python range." >&2 + echo "[ERROR] Neither DEV_PYTHON_REQUIRES nor ${pyproject} names the supported Python range." >&2 return 1 fi sed -n -E 's/^requires-python[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' "${pyproject}" diff --git a/roles/dev-python/tasks/00_core.yml b/roles/dev-python/tasks/00_core.yml index e095bb29d8..248682831b 100644 --- a/roles/dev-python/tasks/00_core.yml +++ b/roles/dev-python/tasks/00_core.yml @@ -8,7 +8,7 @@ ansible.builtin.script: "{{ role_path }}/files/shell/install.sh" environment: SKIP_DOCKER_APT_SANITIZER: "1" - INFINITO_PYTHON_REQUIRES: >- + DEV_PYTHON_REQUIRES: >- {{ lookup('file', lookup('path_absolute', 'pyproject.toml')) | regex_search('(?m)^requires-python\\s*=\\s*"([^"]+)"', '\\1') | first }} diff --git a/tests/unit/python/roles/dev-python/files/test_install.py b/tests/unit/python/roles/dev-python/files/test_install.py index 54207452df..1a358c0201 100644 --- a/tests/unit/python/roles/dev-python/files/test_install.py +++ b/tests/unit/python/roles/dev-python/files/test_install.py @@ -24,7 +24,7 @@ def _call( Args: snippet: bash code evaluated after sourcing; sees ``args`` as ``"$@"``. args: positional arguments handed to the snippet. - requires: value for ``INFINITO_PYTHON_REQUIRES``; ``None`` leaves it + requires: value for ``DEV_PYTHON_REQUIRES``; ``None`` leaves it unset so the script reads the repository's ``pyproject.toml``. Returns: @@ -33,10 +33,10 @@ def _call( env = { key: value for key, value in os.environ.items() - if key != "INFINITO_PYTHON_REQUIRES" + if key != "DEV_PYTHON_REQUIRES" } if requires is not None: - env["INFINITO_PYTHON_REQUIRES"] = requires + env["DEV_PYTHON_REQUIRES"] = requires return subprocess.run( ["bash", "-c", f'source "$1"; shift; {snippet}', "bash", str(SCRIPT), *args], capture_output=True, @@ -210,7 +210,7 @@ class TestBoundsFromRequiresPython(unittest.TestCase): for task in load_yaml_str(read_text(str(ROLE_TASKS))) if "ansible.builtin.script" in task ) - expression = task["environment"]["INFINITO_PYTHON_REQUIRES"] + expression = task["environment"]["DEV_PYTHON_REQUIRES"] def lookup(name: str, term: str) -> str: return {