Repository navigation
fix: Windows py-launcher full-version matching for python_full_version in Pipfile - #6589
Merged
Merged
Conversation
…n in Pipfile Two bugs caused `pipenv install` (from a Pipfile with python_full_version) and `pipenv --python 3.11.9` to fail on Windows even when the requested Python version was installed and discoverable via `py --list-paths`: 1. find_python_from_py_launcher() required split(None, 2) to produce three tokens per line, but non-default py-launcher entries (those without the `*` marker) only produce two tokens. Non-default versions were therefore silently skipped. Fix: require len(parts) >= 2 and take parts[-1] as the path in all cases. 2. PyLauncherFinder stored only the major.minor version that `py --list-paths` reports (e.g. "3.11"), leaving patch=None. Searches requiring a specific patch level (patch=9) therefore never matched. Fix: query each discovered executable for its real version string (e.g. "3.11.9") via get_python_version() so that full-version lookups succeed. Fixes #5893
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.
Summary
Fixes two remaining bugs from #5893 that survived the #6360 refactor, causing
pipenv install(from a Pipfile withpython_full_version) andpipenv --python 3.11.9to fail on Windows even when the requested Python was installed and visible topy --list-paths.Root causes
Bug 1 —
find_python_from_py_launcher()parser skipped non-default versionspy --list-pathsoutput looks like:The function used
split(None, 2)then checkedif len(parts) < 3: continue. Non-default entries (no*) only produce two tokens, so every non-default Python installation was silently skipped.Fix: require
len(parts) >= 2and takeparts[-1]as the executable path in all cases.Bug 2 —
PyLauncherFinderstored onlymajor.minor, breaking patch-level searchespy --list-pathsonly reportsmajor.minor(e.g.3.11). The finder storedpatch=None. When searching for3.11.9(derived frompython_full_version = "3.11.9"in the Pipfile),PythonInfo.matches(patch=9)evaluatedNone == 9 → Falseand returned no result.Fix: query each discovered executable for its real version string (e.g.
3.11.9) viaget_python_version()so that full-version lookups succeed. Falls back gracefully tomajor.minorif the executable can’t be queried.Scenarios now fixed (per @mjhalwa's test matrix from the issue)
pipenv installfrom Pipfile withpython_full_version = "3.11.9"pipenv install --python 3.11.9pipenv install --python 3.11pipenv installfrom Pipfile with onlypython_version = "3.11"The checklist
Fixes #5893
news/directory (news/5893.bugfix.rst)Pull Request opened by Augment Code with guidance from the PR author