Repository navigation
🐛 fix(discovery): find .exe names on Windows PATH - #253
Open
darrenhuai wants to merge 3 commits into
Open
darrenhuai wants to merge 3 commits into
darrenhuai wants to merge 3 commits into
Conversation
On Windows, get_interpreter("python3.exe") or get_interpreter("pythonw.exe") returned None even with that file on
PATH, while "pythonw" found the same pythonw.exe. A name ending in .exe does not parse as a version spec, so it is
looked up on PATH by name, and path_exe_finder appended .exe to it again. The direct candidate became
python3.exe.exe, which never exists.
The regex fallback only matches python[version].exe, so pythonw.exe was never proposed. In a venv it does find
python3.exe, but only after python.exe fails the name check, and then python3.exe is skipped because both share
one base interpreter.
The suffix is now added only when the name does not already end in .exe, ignoring case.
Move the Windows test to the end of test_windows.py so it does not sit in the same spot as other new tests there.
darrenhuai
force-pushed
the
fix/exe-suffixed-name-spec
branch
from
November 10, 2026 01:34
c580402 to
11930ae
Compare
This branch has not been deployed
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.
On Windows, discovery can't find an interpreter on
PATHby a name that already ends in.exe.get_interpreter("pythonw.exe")returnsNonewithpythonw.exeonPATH, whileget_interpreter("pythonw")finds that same file, andvirtualenv -p pythonw.exe(virtualenv 21.15.5 with python-discovery 1.9.4) stops withfailed to find interpreter. You only hit this if you spell out the.exe. A version, or a bare name likepythonw, works. This is currentmain, withPATHset to only theScriptsfolder of a freshpython -m virtualenv --no-seedenvironment (virtualenv putspython.exe,python3.exe,pythonw.exeandpythonw3.exein it):A name ending in
.exedoes not parse as a version spec, so it is looked up onPATHas a literal name.path_exe_finderthen appends.exeon Windows regardless, and the direct candidate it checks in each directory becomespython3.exe.exe. The regex fallback only matchespython[version].exe, which leavespythonw.exeandpythonw3.exeout. It does matchpython3.exe, butpython.exefor the same base interpreter comes first in a virtualenv'sScripts, fails the name check, and_find_interpreterthen skipspython3.exebecause it already tried that base interpreter.path_exe_findernow appends.exeonly when the name does not already end in it, ignoring case, sopython3.exe,PYTHON3.EXEandpythonw.exeare checked as typed. Since #220 the name check looks at the executable found onPATH, and that candidate now passes it. Names without the suffix still get.exeappended. With this branch, all four.exenames above resolve to their own file inScripts, andvirtualenv -p pythonw.execreates the environment. The new tests fail onmain, apart from the case that pins the bare-name behavior.