Fix inline-script env creation for CPython sys.version_info versions (PEP 723) - #1752
Merged
Stella Huang (StellaHuang95) merged 1 commit intoSep 2, 2026
Conversation
Stella Huang (StellaHuang95)
force-pushed
the
copilot/fix-inline-script-version-info
branch
from
September 2, 2026 00:08
5672a75 to
7101a06
Compare
…(PEP 723)
The native locator (pet) reports interpreter versions in CPython's
`sys.version_info` form, e.g. "3.14.3.final.0", which is not valid PEP 440.
The `@renovatebot/pep440` helpers reject that shape, so the inline-script
manager mishandled every such interpreter:
- `areEqualPythonReleases()` returned false even for two identical versions,
because `parseReleaseSegments("3.14.3.final.0")` yields `undefined`. A
freshly created environment was therefore judged not to match its own
requested version, rejected with "Created inline-script environment does not
match the requested cache entry", and deleted — so env creation failed for
scripts without `requires-python`.
- `matchesInstallConstraint()` threw (caught, returning false), so scripts
with `requires-python` found no compatible base interpreter.
Add `normalizeCpythonVersionInfo()`, which converts the `sys.version_info`
form to PEP 440 ("3.14.3.final.0" -> "3.14.3", "3.14.0.candidate.2" ->
"3.14.0rc2"). It preserves the release segments verbatim (no zero-padding, so
`extractLowerBoundVersion`'s `uv python install` targets are unaffected) and
returns any other string unchanged. Apply it inside `parseReleaseSegments()`
(fixing `areEqualPythonReleases` and the interpreter/candidate sorting that
also depend on it) and before `satisfiesPep440()` in
`matchesInstallConstraint()` (fixing the `requires-python` paths).
Stella Huang (StellaHuang95)
force-pushed
the
copilot/fix-inline-script-version-info
branch
from
September 2, 2026 00:47
7101a06 to
6dad4a6
Compare
Rich Chiodo (rchiodo)
approved these changes
Sep 2, 2026
Stella Huang (StellaHuang95)
merged commit Sep 2, 2026
c5520ef
into
microsoft:main
83 of 84 checks passed
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 PEP 723 inline-script environment creation, which currently fails for every interpreter whose version the native locator (
pet) reports in CPython'ssys.version_infoform (e.g.3.14.3.final.0). The venv is provisioned correctly (base interpreter selected,uv venv --seed+ dependencies installed), but is then rejected by a post-creation self-check and deleted, surfacing:Root cause
pet resolvereturns interpreter versions asmajor.minor.micro.releaselevel.serial— e.g."3.14.3.final.0"(verified against the bundledpetin both server mode and CLI, for Python 3.12 / 3.13 / 3.14). That string is not valid PEP 440, and the@renovatebot/pep440helpers reject it:parseReleaseSegments("3.14.3.final.0")→undefined(becauseclean()returnsnull).areEqualPythonReleases()guards onundefinedand returnsfalseeven when both versions are identical, sobuildCacheEntry()treats the freshly-created environment as a version mismatch and deletes it. This blocks creation for scripts withoutrequires-python.satisfies("3.14.3.final.0", ">=3.11")throws (Cannot destructure property 'epoch' of 'input' as it is null).matchesInstallConstraint()catches it and returnsfalse, so scripts withrequires-pythonfind no compatible base interpreter duringselectBaseInterpreter().The repo's existing
PythonVersionclass already parses thesys.version_infoform (somatchesPythonVersionwas unaffected); only the two@renovatebot/pep440-based helpers were not.Fix
Add
normalizeCpythonVersionInfo()incommon/utils/pep440Release.ts, converting thesys.version_infoform to PEP 440:3.14.3.final.0→3.14.33.14.0.candidate.2→3.14.0rc2(and.alpha.N/.beta.N→aN/bN)3.13stays3.13andextractLowerBoundVersion()'suv python installtargets are unchangedsys.version_infostring is returned unchangedApply it in:
parseReleaseSegments()→ fixesareEqualPythonReleases()(create + reuse cache validation) and the interpreter/candidate version sorting that also depends on itmatchesInstallConstraint()(beforesatisfiesPep440) → fixes therequires-pythonbase-selection and reuse pathsScope is limited to the inline-script feature:
parseReleaseSegmentsis used only by inline-script code, andmatchesInstallConstraintis private to the inline-script manager. No change to venv / system / conda / other environment resolution.Testing
normalizeCpythonVersionInfoandparseReleaseSegments(final + prerelease forms, whitespace, no zero-padding, non-matching passthrough).3.14.3.final.0, both with and withoutrequires-python(both previously returnedundefined).tsc(npm run compile-tests) andeslintclean.Impact / benefit
Restores end-to-end PEP 723 inline-script environment creation on setups where the bundled
petreportssys.version_info-style versions (observed withpet 0.1.0-dev.428887on Windows for Python 3.12–3.14). Without this fix the "Set up environment" / CodeLens flow provisions the venv and then silently discards it, so users cannot create an inline-script environment at all.Out of scope
The same non-PEP-440 version string also makes
shortenVersionString()return"3.14.3.final.0"verbatim (a cosmetic display artifact that affects all pet-resolved environments, not just inline scripts). That is a separate, non-blocking issue and is intentionally left for a follow-up to keep this fix's blast radius minimal.