Skip to content

Commit 7207b3f

Browse files
authored
fix: support uv 0.10.0 (#1055)
* fix: support uv 0.10.0 Signed-off-by: Henry Schreiner <henryfs@princeton.edu> * tests: test for --clear Signed-off-by: Henry Schreiner <henryfs@princeton.edu> --------- Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
1 parent 11eee27 commit 7207b3f

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

nox/virtualenv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ def create(self) -> bool:
802802
self._resolved_interpreter if self.interpreter else sys.executable,
803803
self.location,
804804
]
805+
if version.Version("0.8") <= UV_VERSION:
806+
cmd += ["--clear"]
805807
else:
806808
cmd = [self._resolved_interpreter, "-m", "venv", self.location]
807809
cmd.extend(self.venv_params)

tests/test_virtualenv.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,36 @@ def test_condaenv_detection(make_conda: Callable[..., tuple[CondaEnv, Path]]) ->
283283
assert dir_.samefile(output_match.group("env_dir"))
284284

285285

286+
def test_create_args_new_uv(
287+
make_one: Callable[..., tuple[VirtualEnv, Path]],
288+
monkeypatch: pytest.MonkeyPatch,
289+
) -> None:
290+
run_mock = mock.Mock()
291+
monkeypatch.setattr(nox.command, "run", run_mock)
292+
monkeypatch.setattr(nox.virtualenv, "UV", "uv")
293+
monkeypatch.setattr(nox.virtualenv, "HAS_UV", True)
294+
monkeypatch.setattr(nox.virtualenv, "UV_VERSION", version.Version("0.10.0"))
295+
venv, _ = make_one(venv_backend="uv")
296+
venv.create()
297+
run_mock.assert_called_once()
298+
assert run_mock.call_args.args[0][-1] == "--clear"
299+
300+
301+
def test_create_args_old_uv(
302+
make_one: Callable[..., tuple[VirtualEnv, Path]],
303+
monkeypatch: pytest.MonkeyPatch,
304+
) -> None:
305+
run_mock = mock.Mock()
306+
monkeypatch.setattr(nox.virtualenv, "UV", "uv")
307+
monkeypatch.setattr(nox.virtualenv, "HAS_UV", True)
308+
monkeypatch.setattr(nox.virtualenv, "UV_VERSION", version.Version("0.7.0"))
309+
monkeypatch.setattr(nox.command, "run", run_mock)
310+
venv, _ = make_one(venv_backend="uv")
311+
venv.create()
312+
run_mock.assert_called_once()
313+
assert run_mock.call_args.args[0][-1] != "--clear"
314+
315+
286316
@has_uv
287317
def test_uv_creation(
288318
make_one: Callable[..., tuple[VirtualEnv, Path]],

0 commit comments

Comments
 (0)