🐛 fix(venv): resolve env names with trailing digits correctly#313
Merged
gaborbernat merged 2 commits intotox-dev:mainfrom Mar 12, 2026
Merged
🐛 fix(venv): resolve env names with trailing digits correctly#313gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat merged 2 commits intotox-dev:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Environments with non-Python names that happen to end in digits — like
doc8,flake8, orcheck2— fail withcould not find python interpreter with spec(s): doc8since v1.33.0. 🐛 This happens becausePythonSpec.from_string_specgreedily parses any<letters><digits>pattern as a Python spec (e.g.doc8becomesimpl="doc" major=8).The upstream fix added
has_python_factorvalidation to reject specs when the env name lacks proper Python factors. However, this broke implementation-only env names likepypyorcpython(withignore_base_python_conflict=true) because they haveenv_spec.major=None, failing themajor is not None and has_python_factorcheck.This PR adds an
eliffallback that delegates to tox'sextract_base_pythonwhich 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