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 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-11-03 19:55:27 +01:00
1 parent b9d9e5dd54
commit 0bdb14cc1d
3 files changed
+8 -8

No files matched your search

+3 -3
View File
@@ -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}"
+1 -1
View File
@@ -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 }}
@@ -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 {