Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/pyhc_actions/env_compat/uv_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import os
import re
import shutil
import subprocess
Expand Down Expand Up @@ -385,13 +384,14 @@ def _report_error(
if temp_constraints:
command.extend(["-c", temp_constraints])

# We used to force UV_NO_CACHE=1 here for fully cold resolves, but removed that
# override to improve env-compat performance across repeated extras checks.
result = subprocess.run(
command,
capture_output=True,
text=True,
# Handle both directory paths (setup.py) and file paths (pyproject.toml)
cwd=pyproject_path if pyproject_path.is_dir() else pyproject_path.parent,
env={**os.environ, "UV_NO_CACHE": "1"},
)

if result.returncode == 0:
Expand Down
37 changes: 37 additions & 0 deletions tests/test_compat_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,43 @@ def fake_run(cmd, *args, **kwargs):
assert "--python-version" in captured["cmd"]
assert "3.12" in captured["cmd"]

def test_uv_compile_does_not_force_no_cache(self, tmp_path, monkeypatch):
pyproject = tmp_path / "pyproject.toml"
pyproject.write_text(
"""
[project]
name = "demo"
"""
)

captured: dict[str, object] = {}

class DummyResult:
returncode = 0
stdout = ""
stderr = ""

def fake_run(cmd, *args, **kwargs):
captured["cmd"] = cmd
captured["env"] = kwargs.get("env")
return DummyResult()

monkeypatch.setattr("pyhc_actions.env_compat.uv_resolver.find_uv", lambda: "/usr/bin/uv")
monkeypatch.setattr("pyhc_actions.env_compat.uv_resolver.subprocess.run", fake_run)

reporter = Reporter(title="Test", output=StringIO(), github_actions=False)
ok, _conflicts = check_compatibility(
pyproject_path=pyproject,
pyhc_packages=["numpy>=1.20"],
pyhc_constraints=[],
pyhc_python="3.12.0",
reporter=reporter,
)

assert ok is True
if isinstance(captured["env"], dict):
assert captured["env"].get("UV_NO_CACHE") != "1"

def test_excludes_same_package_when_pyhc_entry_has_extras(self, tmp_path, monkeypatch):
pyproject = tmp_path / "pyproject.toml"
pyproject.write_text(
Expand Down
Loading