Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error caused by a bad base_python path #3122

Merged
merged 3 commits into from
Sep 8, 2023
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
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