fix: resolve full patch version from py-launcher executable#166
Merged
fix: resolve full patch version from py-launcher executable#166
Conversation
`py --list-paths` only reports major.minor (e.g. "3.11"), so PyLauncherFinder stored patch=None for every entry. Searches requiring a specific patch level (e.g. patch=9 from python_full_version="3.11.9") therefore never matched. After parsing the version string from the py launcher, query the discovered executable for its real version string (e.g. "3.11.9") via get_python_version(). Fall back gracefully to major.minor if the executable cannot be queried.
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.
Problem
py --list-pathsonly reportsmajor.minor(e.g.3.11), soPyLauncherFinderstoredpatch=Nonefor every entry it created.Callers that searched for a specific full version string — such as
3.11.9coming frompython_full_version = "3.11.9"in a Pipfile — received no match becausePythonInfo.matches(patch=9)evaluatedNone == 9 → False, even when the exact Python version was installed and visible topy --list-paths.This is the underlying cause of pypa/pipenv#5893.
Fix
After parsing the
major.minorversion string from the py launcher, query the discovered executable for its real version string (e.g.3.11.9) viaget_python_version(). The resolved version populates all fields ofPythonInfo— includingpatch— so that full-version lookups succeed.If the executable cannot be queried (e.g. permission error, timeout), the code falls back gracefully to the
major.minorstring provided by the py launcher, preserving the existing behaviour.Behaviour before / after
find_python_version("3.11")find_python_version("3.11.9")patch=Nonemismatchfind_python_version("3.11.9")Pull Request opened by Augment Code with guidance from the PR author