fix(pm): keep streamed build-backend output without uv's DEBUG spew

The previous commit dropped --verbose and broke the contract that native
build output streams live (tests/pm/test_environment_build.py). uv only
forwards backend output at DEBUG level, so keep --verbose and scope it with
RUST_LOG=uv_build_frontend=debug: the backend's own lines stream, the
interpreter/cache/reflink internals stay silent (2 lines on a no-op sync
instead of ~200 on both uv 0.11 and the pinned 0.12.3).
This commit is contained in:
ethernet
2026-09-21 18:48:58 -04:00
parent 2bdb7d338c
commit fdf9cebe2c
2 changed files with 11 additions and 4 deletions

View File

@@ -262,9 +262,12 @@ class PythonEnvironment:
command.append("--offline")
try:
if self.output is not None:
# No --verbose: it is uv's DEBUG level and buries the progress
# lines under interpreter/cache internals on every streamed run.
# Build-backend output still arrives with the failure.
# uv hides build-backend output until failure without verbose mode,
# but --verbose alone is uv's DEBUG level: ~200 lines of interpreter
# and cache internals on every streamed run. RUST_LOG scopes it to the
# build frontend, so only the backend's own lines reach the user.
command.append("--verbose")
env.setdefault("RUST_LOG", "uv_build_frontend=debug")
return _run_streaming(command, cwd=cwd, env=env, timeout=timeout, output=self.output)
return subprocess.run(command, cwd=str(cwd), env=env, capture_output=True,
text=True, encoding="utf-8", errors="replace", timeout=timeout)

View File

@@ -57,15 +57,19 @@ def test_streamed_runs_do_not_request_uv_debug_output(tmp_path, monkeypatch):
from pm import environment
seen: list[list[str]] = []
kwargs_seen: list[dict] = []
def record(command, **kwargs):
seen.append(command)
kwargs_seen.append(kwargs)
return subprocess.CompletedProcess(command, 0, "", "")
monkeypatch.setattr(environment, "_run_streaming", record)
PythonEnvironment(uv=tmp_path / "uv", python=tmp_path / "python", destination=tmp_path / "venv",
cache=tmp_path / "cache", env={}, output=io.StringIO())._run(["sync"], cwd=tmp_path, timeout=5)
assert seen and not {"--verbose", "-v"} & set(seen[0])
(command,), (kwargs,) = seen, kwargs_seen
# Verbose only where the build backend speaks; uv's own DEBUG stays silent.
assert "--verbose" in command and kwargs["env"]["RUST_LOG"] == "uv_build_frontend=debug"
def test_uv_timeout_names_the_mirror_knobs(tmp_path, monkeypatch):