Skip to content

🐛 fix(venv): resolve env names with trailing digits correctly#313

Merged
gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat:311
Mar 12, 2026
Merged

🐛 fix(venv): resolve env names with trailing digits correctly#313
gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat:311

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

@gaborbernat gaborbernat commented Mar 12, 2026

Environments with non-Python names that happen to end in digits — like doc8, flake8, or check2 — fail with could not find python interpreter with spec(s): doc8 since v1.33.0. 🐛 This happens because PythonSpec.from_string_spec greedily parses any <letters><digits> pattern as a Python spec (e.g. doc8 becomes impl="doc" major=8).

The upstream fix added has_python_factor validation to reject specs when the env name lacks proper Python factors. However, this broke implementation-only env names like pypy or cpython (with ignore_base_python_conflict=true) because they have env_spec.major=None, failing the major is not None and has_python_factor check.

This PR adds an elif fallback that delegates to tox's extract_base_python which uses proper regexes matching only known Python implementations (py, cpython, pypy, etc.). This preserves the upstream fix while correctly handling implementation-only specs.

Fixes #311

@gaborbernat gaborbernat added the bug Something isn't working label Mar 12, 2026
PythonSpec.from_string_spec parses any <letters><digits> pattern as a
Python spec (e.g. "doc8" becomes impl="doc" major=8). The PR tox-dev#308 check
`env_spec.major is not None` was insufficient since it matched these
false positives, causing envs like doc8/flake8 to pass `-p doc8` to uv
and fail with "could not find python interpreter".

Now the absolute-path branch validates specs in three tiers: pure version
strings (impl is None), known Python implementations via tox's own
extract_base_python, and finally fallback to probing the interpreter.

Fixes tox-dev#311
@gaborbernat gaborbernat merged commit 8cee50b into tox-dev:main Mar 12, 2026
16 checks passed
@gaborbernat gaborbernat deleted the 311 branch March 12, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting venv prompts causes failures

1 participant