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 {