Add uv fallback for inline script environments (PEP 723 PR 6/16) - #1696
Add uv fallback for inline script environments (PEP 723 PR 6/16)#1696Stella Huang (StellaHuang95) wants to merge 3 commits into
Conversation
|
🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR. |
2c8302b to
d58cf31
Compare
Eduardo Villalpando Mello (edvilme)
left a comment
There was a problem hiding this comment.
:)
3521a00 to
af8592c
Compare
Eleanor Boyd (eleanorjboyd)
left a comment
There was a problem hiding this comment.
Thanks for adding this fallback. I found two related gaps that need addressing:
-
In
InlineScriptEnvManager.create, fallback interpreter selection and installation happen before the per-script entry is added topendingCreations. Concurrentcreate()calls for the same script can therefore both display prompts and launch competing uv/Python installations. Please move the fallback work inside the deduplicated operation. -
The new uv-version-lookup installation path is not effectively exercised. The manager tests stub
ensureUvForInlineScriptVersionLookup()to return true, while the installer tests cover only dismissing its prompt. Please add coverage for accepted installation success, installation failure, uv remaining unavailable/restart-required, cancellation, and concurrent same-script creation.
Add consent-gated uv installation when no installed interpreter satisfies a script. Coalesce matching installs, skip prompts for quick create, and directly resolve a successful installation when discovery is stale or unavailable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1a9f6ba1-9bd3-4664-bc25-a0d34d7a2e91
af8592c to
c6abcf8
Compare
Thanks, both gaps are addressed.
|
Coalesce identical inline-script setup requests before interpreter installation and cover uv bootstrap success and failure paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1a9f6ba1-9bd3-4664-bc25-a0d34d7a2e91
| private readonly pendingSetups = new Map<string, Promise<PythonEnvironment | undefined>>(); | ||
| private readonly pendingCreations = new Map<string, Promise<PythonEnvironment | undefined>>(); | ||
| private readonly directlyResolvedBaseInterpreters = new Map<string, PythonEnvironment>(); | ||
| private baseInterpreterInstallationQueue: Promise<void> = Promise.resolve(); |
There was a problem hiding this comment.
What is this used for?
Roadmap context
This is PR 6 of 16 in the PEP 723 inline-script roadmap. It extends the PR 5
create()happy path with the missing-compatible-interpreter fallback.InlineScriptEnvManagerskeletoncreate()happy pathcreate()uv-install fallbackget/set+ Memento)Why this PR
PR 5 can create or reuse an inline-script environment when an installed base interpreter already satisfies the script's
requires-python. It deliberately stops when no compatible interpreter exists.This PR adds the consent-gated fallback for that case:
What this PR does
Adds the inline-script fallback to
InlineScriptEnvManager.create()Selects a safe uv target from
requires-python>=3.13→3.13and==3.13.1→3.13.1.>=3.13.2,!=3.13.2without installing the excluded floor.c1→rc1) before passing a version to uv.Extends the uv installer's consent flow
Handles stale discovery after installation
requires-python, and canonicalizes its path before creating the cached environment.Examples
requires-python>=3.133.13selector==3.13.13.13.1without requiring a catalog lookup>=3.11,<3.123.11.xrelease>=3.13.2,!=3.13.23.13.2and choose a compatible advertised release>=3.15.0a1,<3.16>=3.14,<3.16Safety and concurrency
Tests
Coverage includes:
npm run compile-tests,npm run lint, the full unit suite, and the focused inline-script/uv suites are clean.User impact
No default-path user impact yet. This completes an internal Phase 2 manager capability. Automatic routing and user-facing entry points arrive in later roadmap PRs.
When those entry points are wired, users whose scripts require an unavailable Python will be able to approve installing a compatible interpreter rather than having environment creation stop.