Repository navigation
Expand file tree
/
Copy pathcheck_distributions.py
More file actions
50 lines (44 loc) · 1.83 KB
/
Copy pathcheck_distributions.py
File metadata and controls
50 lines (44 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Smoke-test wheel and sdist installations."""
# ruff: noqa: INP001, S603, S607 - Standalone helper using explicit uv arguments.
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
def check_distributions(distributions: Path, version: str) -> None:
"""Check both distributions in isolated environments."""
wheels, sdists = list(distributions.glob("*.whl")), list(distributions.glob("*.tar.gz"))
if len(wheels) != 1 or len(sdists) != 1:
raise ValueError("Expected exactly one wheel and one source distribution")
with tempfile.TemporaryDirectory(prefix="typesafe-distributions-") as temporary:
consumer = Path(temporary)
installation_check = consumer / "check_installed_distribution.py"
shutil.copyfile(Path(__file__).with_name("check_installed_distribution.py"), installation_check)
subprocess.run(
["uv", "build", "--wheel", str(sdists[0].resolve()), "--out-dir", str(consumer / "rebuilt")],
cwd=consumer,
check=True,
)
rebuilt = list((consumer / "rebuilt").glob("*.whl"))
if len(rebuilt) != 1:
raise ValueError("Expected one wheel rebuilt from the source distribution")
for wheel in [wheels[0].resolve(), rebuilt[0]]:
subprocess.run(
[
"uv",
"run",
"--isolated",
"--no-project",
"--python",
sys.executable,
"--with",
str(wheel),
"python",
str(installation_check),
version,
],
cwd=consumer,
check=True,
)
if __name__ == "__main__":
check_distributions(Path(sys.argv[1]), sys.argv[2])