diff --git a/docs/changelog/3105.bugfix.rst b/docs/changelog/3105.bugfix.rst new file mode 100644 index 000000000..dd87507cd --- /dev/null +++ b/docs/changelog/3105.bugfix.rst @@ -0,0 +1 @@ +Handle ``FileNotFoundError`` when the ``base_python`` interpreter doesn't exist diff --git a/src/tox/tox_env/python/virtual_env/api.py b/src/tox/tox_env/python/virtual_env/api.py index 706f7ea44..c1c507247 100644 --- a/src/tox/tox_env/python/virtual_env/api.py +++ b/src/tox/tox_env/python/virtual_env/api.py @@ -132,7 +132,7 @@ def _get_python(self, base_python: list[str]) -> PythonInfo | None: # noqa: ARG # the base pythons are injected into the virtualenv_env_vars, so we don't need to use it here try: interpreter = self.creator.interpreter - except RuntimeError: # if can't find + except (FileNotFoundError, RuntimeError): # Unable to find the interpreter return None return PythonInfo( implementation=interpreter.implementation, diff --git a/tests/tox_env/python/test_python_api.py b/tests/tox_env/python/test_python_api.py index 159d9d772..e56d9d698 100644 --- a/tests/tox_env/python/test_python_api.py +++ b/tests/tox_env/python/test_python_api.py @@ -277,3 +277,10 @@ def test_list_installed_deps_explicit_cli( assert "pip==" in result.out else: assert "pip==" not in result.out + + +def test_usedevelop_with_nonexistent_basepython(tox_project: ToxProjectCreator) -> None: + ini = "[testenv]\nusedevelop = true\n[testenv:unused]\nbasepython = /nonexistent/bin/python" + project = tox_project({"tox.ini": ini}) + result = project.run() + assert result.code == 0