Skip to content

Commit

Permalink
Fix error caused by a bad base_python path (#3122)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbruno25 committed Sep 8, 2023
1 parent 381e37a commit 21c0c90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog/3105.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle ``FileNotFoundError`` when the ``base_python`` interpreter doesn't exist
2 changes: 1 addition & 1 deletion src/tox/tox_env/python/virtual_env/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions tests/tox_env/python/test_python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 21c0c90

Please sign in to comment.