Skip to content

The agent that grows with you

test(pm): sealing tests see a build-machine .pth to prune

ethernet031acd8dea22
diff --git a/tests/pm/_fixtures.py b/tests/pm/_fixtures.py
index 616470fc8f5..38aa541fc32 100644
--- a/tests/pm/_fixtures.py
+++ b/tests/pm/_fixtures.py
@@ -20,13 +20,14 @@ import zipfile
import pytest
-def _wheel(directory: Path, name: str, version: str = "1.0", requirements=()) -> Path:
+def _wheel(directory: Path, name: str, version: str = "1.0", requirements=(), extra=None) -> Path:
metadata = f"{name}-{version}.dist-info"
entries = {
f"{name}/__init__.py": f"__version__ = {version!r}\n",
f"{metadata}/METADATA": f"Metadata-Version: 2.1\nName: {name}\nVersion: {version}\n"
+ "".join(f"Requires-Dist: {requirement}\n" for requirement in requirements),
f"{metadata}/WHEEL": "Wheel-Version: 1.0\nRoot-Is-Purelib: true\nTag: py3-none-any\n",
+ **(extra or {}),
}
entries[f"{metadata}/RECORD"] = "".join(f"{path},,\n" for path in entries)
wheel = directory / f"{name}-{version}-py3-none-any.whl"
diff --git a/tests/pm/test_build_operations.py b/tests/pm/test_build_operations.py
index 1f541c381b8..142de4a6c62 100644
--- a/tests/pm/test_build_operations.py
+++ b/tests/pm/test_build_operations.py
@@ -282,7 +282,9 @@ def test_requirements_build_installs_offline_markers_and_seals_only_build_pth(tm
wheels = tmp_path / "wheels with spaces"
wheels.mkdir()
_wheel(wheels, "leaf_dep")
- _wheel(wheels, "app_dep", requirements=["leaf-dep==1.0"])
+ # A build-machine pointer sealing must strip, beside one that must survive.
+ _wheel(wheels, "app_dep", requirements=["leaf-dep==1.0"],
+ extra={"__editable__.app_dep-1.0.pth": "# build machine path\n", "app_dep.pth": "\n"})
out = tmp_path / "destination with spaces"
# Ambient project and interpreter settings cannot escape the explicit build.
(tmp_path / "uv.toml").write_text('required-version="<0.1"\n', encoding="utf-8")
@@ -301,8 +303,8 @@ def test_requirements_build_installs_offline_markers_and_seals_only_build_pth(tm
))
assert result == ["1.0", "1.0", sys.base_prefix, True]
assert executable.parent.parent == out
- # uv 0.13 stopped writing the distutils shim (astral-sh/uv#22096), so neither arm has it.
- assert not list(out.rglob("_virtualenv.pth"))
+ assert bool(list(out.rglob("__editable__.app_dep-1.0.pth"))) is not sealed
+ assert list(out.rglob("app_dep.pth")), "load-bearing .pth must survive sealing"
assert not poison.exists()
assert not Path(build_tools["HERMES_HOME"]).exists()
assert dict(os.environ) == before
diff --git a/tests/pm/test_environment_build.py b/tests/pm/test_environment_build.py
index a7a426c6453..ac90e6b20ee 100644
--- a/tests/pm/test_environment_build.py
+++ b/tests/pm/test_environment_build.py
@@ -108,6 +108,8 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
dist = "construction_root-1.dist-info"
entries = {
"construction_root.pth": str(Path.cwd()) + "\\n",
+ # A build-machine pointer of the kind sealing must strip (pm.environment.prune_site_pth).
+ "__editable__.construction_root-1.pth": "# build machine path\\n",
dist + "/METADATA": "Metadata-Version: 2.1\\nName: construction-root\\nVersion: 1\\nRequires-Dist: base-dep==1.0\\n",
dist + "/WHEEL": "Wheel-Version: 1.0\\nRoot-Is-Purelib: true\\nTag: py3-none-any\\n",
}
@@ -155,8 +157,7 @@ def test_public_build_installs_all_extras_at_explicit_destination(installable_pr
assert executable.parent.parent == tmp_path / "native environment"
assert not (tmp_path / "wrong-environment").exists()
assert "root_app" not in sys.modules
- # uv 0.13 stopped writing the distutils shim (astral-sh/uv#22096), so neither arm has it.
- assert not (site / "_virtualenv.pth").exists()
+ assert (site / "__editable__.construction_root-1.pth").exists() is not sealed
assert (site / "construction_root.pth").is_file(), "load-bearing .pth must survive sealing"
assert (source / "uv.lock").read_bytes() == locked
assert dict(os.environ) == before