Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -184,16 +191,19 @@ 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,
str(interpreter),
"-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,
)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_package_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down