Skip to content

Commit 83543ea

Browse files
authored
Support skip_missing_interpreters on uv==0.8.0 (#222) (#223)
In uv 0.8.0 the exit code for `uv venv` command changed from 1 to 2 in case the python interpreter is not found. This change handles both codes.
1 parent 3849b7d commit 83543ea

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/tox_uv/_venv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def create_python_env(self) -> None:
221221
cmd.append(str(self.venv_dir))
222222
outcome = self.execute(cmd, stdin=StdinSource.OFF, run_id="venv", show=None)
223223

224-
if self.core["skip_missing_interpreters"] and outcome.exit_code == 1:
224+
if self.core["skip_missing_interpreters"] and outcome.exit_code in {1, 2}:
225225
msg = f"could not find python interpreter with spec(s): {version_spec}"
226226
raise Skip(msg)
227227

tests/test_tox_uv_venv.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,23 @@ def test_uv_venv_na(tox_project: ToxProjectCreator) -> None:
244244
result.assert_failed(code=-1)
245245

246246

247+
def test_uv_venv_na_uv_072(tox_project: ToxProjectCreator) -> None:
248+
# Test uv==0.7.2
249+
# skip_missing_interpreters is true by default
250+
project = tox_project({"tox.ini": "[testenv]\npackage=skip\nbase_python=1.0\nrequires=uv==0.7.2"})
251+
result = project.run("-vv")
252+
253+
# When a Python interpreter is missing in a pytest environment, project.run
254+
# return code is equal to -1
255+
result.assert_failed(code=-1)
256+
257+
247258
def test_uv_venv_skip_missing_interpreters_fail(tox_project: ToxProjectCreator) -> None:
248259
project = tox_project({
249260
"tox.ini": "[tox]\nskip_missing_interpreters=false\n[testenv]\npackage=skip\nbase_python=1.0"
250261
})
251262
result = project.run("-vv")
252-
result.assert_failed(code=1)
263+
result.assert_failed(code=2)
253264

254265

255266
def test_uv_venv_skip_missing_interpreters_pass(tox_project: ToxProjectCreator) -> None:

0 commit comments

Comments
 (0)