From 2ecca3c8b3dd01e57263582cdf0d3f9c76df97cc Mon Sep 17 00:00:00 2001 From: Yernat Yestekov Date: Thu, 13 Aug 2026 13:49:23 -0700 Subject: [PATCH] ci: prove verification under matrix interpreter --- noxfile.py | 18 ++++++++++++++---- tests/test_package_identity.py | 12 ++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/noxfile.py b/noxfile.py index f339b9b..c3c4991 100644 --- a/noxfile.py +++ b/noxfile.py @@ -25,7 +25,11 @@ def _run(session: nox.Session, *args: str, env: dict[str, str] | None = None) -> def _uv(session: nox.Session, *args: str) -> None: - _run(session, "uv", "run", "--frozen", *args) + command = ["uv", "run", "--frozen"] + selected_python = os.environ.get("UV_PYTHON") + if selected_python is not None: + command.extend(("--python", selected_python)) + _run(session, *command, *args) def _hygiene(session: nox.Session) -> None: @@ -84,6 +88,9 @@ def _build_smoke(session: nox.Session) -> None: source_dist.mkdir() wheel_dist.mkdir() expected_version = _canonical_version() + selected_python = os.environ.get( + "UV_PYTHON", f"{sys.version_info.major}.{sys.version_info.minor}" + ) _uv(session, "python", "-c", "import hatchling") _run( @@ -152,7 +159,7 @@ def _build_smoke(session: nox.Session) -> None: "--output-file", str(runtime_requirements), ) - _run(session, "uv", "venv", "--python", "3.11", str(environment)) + _run(session, "uv", "venv", "--python", selected_python, str(environment)) interpreter = ( environment / ("Scripts/python.exe" if os.name == "nt" else "bin/python") ).absolute() @@ -184,6 +191,7 @@ def _build_smoke(session: nox.Session) -> None: clean_environment.pop("PYTHONPATH", None) clean_environment["PYTHONSAFEPATH"] = "1" clean_environment["EXPECTED_LILRAE_VERSION"] = expected_version + clean_environment["EXPECTED_PYTHON"] = selected_python with session.chdir(temporary): _run( session, @@ -191,9 +199,11 @@ def _build_smoke(session: nox.Session) -> None: "-I", "-c", ( - "import importlib.metadata as metadata, os; import lilrae; " + "import importlib.metadata as metadata, os, sys; import lilrae; " "assert metadata.version('lilrae') == lilrae.__version__ " - "== os.environ['EXPECTED_LILRAE_VERSION']" + "== os.environ['EXPECTED_LILRAE_VERSION']; " + "assert sys.version_info[:2] == tuple(int(part) for part in " + "os.environ['EXPECTED_PYTHON'].split('.'))" ), env=clean_environment, ) diff --git a/tests/test_package_identity.py b/tests/test_package_identity.py index be58126..c40c30e 100644 --- a/tests/test_package_identity.py +++ b/tests/test_package_identity.py @@ -25,6 +25,18 @@ def test_public_package_and_cli_have_one_identity() -> None: assert __version__ +def test_wheel_smoke_uses_and_proves_the_selected_matrix_interpreter() -> None: + noxfile = (ROOT / "noxfile.py").read_text(encoding="utf-8") + + assert "selected_python = os.environ.get(" in noxfile + assert '"UV_PYTHON"' in noxfile + assert 'command.extend(("--python", selected_python))' in noxfile + assert '"uv", "venv", "--python", selected_python' in noxfile + assert 'clean_environment["EXPECTED_PYTHON"] = selected_python' in noxfile + assert "assert sys.version_info[:2] == tuple(int(part) for part in " in noxfile + assert '"uv", "venv", "--python", "3.11"' not in noxfile + + def test_cli_reports_the_distribution_version_without_backend_claims() -> None: result = subprocess.run( [sys.executable, "-m", "lilrae.cli", "--version"],