Skip to content

Commit 474c93f

Browse files
committed
Make release preflight import source checkout
1 parent 5c7d606 commit 474c93f

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

tests/test_release_preflight.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
import re
45
from pathlib import Path
56

@@ -64,6 +65,14 @@ def test_pipewire_gobject_build_environment_error_lists_missing_tools(monkeypatc
6465
raise AssertionError("Expected missing pipewire-gobject build tool to fail")
6566

6667

68+
def test_release_preflight_source_tree_python_env_prepends_src(monkeypatch) -> None:
69+
monkeypatch.setenv("PYTHONPATH", "/already-there")
70+
71+
env = release_preflight.source_tree_python_env()
72+
73+
assert env["PYTHONPATH"].split(os.pathsep) == [str(release_preflight.ROOT / "src"), "/already-there"]
74+
75+
6776
def test_release_preflight_runs_headless_pipewire_runtime_smoke(monkeypatch) -> None:
6877
commands: list[list[str | Path]] = []
6978

tools/release_preflight.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ def format_command(command: list[str | Path]) -> str:
6868
return " ".join(shlex.quote(str(part)) for part in command)
6969

7070

71-
def run(command: list[str | Path], *, cwd: Path = ROOT) -> None:
71+
def run(command: list[str | Path], *, cwd: Path = ROOT, env: dict[str, str] | None = None) -> None:
7272
print(f"\n$ {format_command(command)}", flush=True)
73-
subprocess.run([str(part) for part in command], cwd=cwd, check=True)
73+
command_env = None
74+
if env is not None:
75+
command_env = os.environ.copy()
76+
command_env.update(env)
77+
subprocess.run([str(part) for part in command], cwd=cwd, check=True, env=command_env)
7478

7579

7680
def git_stdout(*args: str | Path) -> str:
@@ -90,6 +94,14 @@ def require_tools(*tools: str) -> None:
9094
raise SystemExit(f"Missing required release tool(s): {', '.join(missing)}")
9195

9296

97+
def source_tree_python_env() -> dict[str, str]:
98+
src_path = str(ROOT / "src")
99+
pythonpath = os.environ.get("PYTHONPATH")
100+
if pythonpath:
101+
src_path = os.pathsep.join((src_path, pythonpath))
102+
return {"PYTHONPATH": src_path}
103+
104+
93105
def bounded_int_env(name: str, default: int, *, minimum: int, maximum: int) -> str:
94106
value = os.environ.get(name, str(default)).strip()
95107
try:
@@ -474,7 +486,7 @@ def main() -> int:
474486
run([python, "-m", "ruff", "check", "."])
475487
run([python, "-m", "ruff", "format", "--check", "."])
476488
run([python, "-m", "pytest", "-q"])
477-
run([python, "-m", "mini_eq", "--check-deps"])
489+
run([python, "-m", "mini_eq", "--check-deps"], env=source_tree_python_env())
478490
run_headless_pipewire_runtime_smoke(python)
479491
run(["appstreamcli", "validate", "--no-net", ROOT / "data/io.github.bhack.mini-eq.metainfo.xml"])
480492
run(["desktop-file-validate", ROOT / "data/io.github.bhack.mini-eq.desktop"])

0 commit comments

Comments
 (0)