Skip to content

Harden uv Python compatibility for inline scripts - #1733

Merged
Stella Huang (StellaHuang95) merged 1 commit into
microsoft:mainfrom
StellaHuang95:copilot/pep723-uv-compat
Aug 26, 2026
Merged

Harden uv Python compatibility for inline scripts#1733
Stella Huang (StellaHuang95) merged 1 commit into
microsoft:mainfrom
StellaHuang95:copilot/pep723-uv-compat

Conversation

@StellaHuang95

Copy link
Copy Markdown
Contributor

Context

Inline-script environment creation selects an installed Python when possible and falls back to installing a compatible Python with uv. The fallback has to use the same PEP 440 semantics before and after installation; otherwise setup can download Python successfully and then reject it.

This remains behind the undeclared, default-off inline-script feature flag.

Why this change is needed

Two compatibility paths were inconsistent:

  • A directly resolved Python was checked by the release-segment-only helper before the manager's strict PEP 440 check. This could reject a compatible final release, such as Python 3.15.0 for !=3.15.0rc2.
  • A short exact requirement such as ==3.13 could be passed to uv as the broad selector 3.13. uv may install a later 3.13 patch, while strict PEP 440 equality requires 3.13.0.

The default uv catalog can also omit older patch releases. A strict short-exact lookup therefore needs an all-versions catalog to find 3.13.0 after newer 3.13 releases exist.

What changed

  • Direct post-install resolution now keeps the existing Python 3, error, executable, and canonical-path guards while using strict PEP 440 compatibility.
  • Short exact equality resolves through a concrete uv catalog result instead of forwarding a broad minor selector.
  • Only the short-exact path requests uv python list --all-versions; existing catalog callers retain their previous command arguments.
  • Fully specified exact versions, simple lower bounds, bounded ranges, exclusions, prerelease/dev requirements, no-requirement behavior, and quick-create prompt suppression remain unchanged.

Behavior and compatibility

  • No setting, command, menu, view, or status-bar contribution is added.
  • The inline manager remains unregistered while the feature flag is off.
  • Non-inline uv and package-management flows keep their existing behavior.
  • Failures remain fail-closed: no incompatible cache environment is created.

Reviewer guide

  1. Review the strict direct-resolution guard in inlineScript/envManager.ts.
  2. Review short-exact catalog selection and the allVersions option.
  3. Review uv command-argument tests, then the manager compatibility regressions.

Validation

  • npm run compile-tests --silent
  • Targeted inline manager, uv installer, and interpreter suites: 311 passing
  • ESLint on changed TypeScript files
  • git diff --check

@StellaHuang95 Stella Huang (StellaHuang95) added the feature-request Request for new features or functionality label Aug 25, 2026
@heejaechang

Heejae Chang (heejaechang) commented Aug 25, 2026

Copy link
Copy Markdown

🔒 Automated review in progress — Heejae Chang (@heejaechang) is auto-reviewing this PR.

@heejaechang

Copy link
Copy Markdown

Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@heejaechang Heejae Chang (heejaechang) added the review-auto:approved Automated review: no blocking findings (approval posted). label Aug 25, 2026
Comment on lines +291 to +295
const args = ['python', 'list'];
if (options?.allVersions) {
args.push('--all-versions');
}
args.push('--output-format', 'json');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add --output-format json to the args list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean? it is added to the args list

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@StellaHuang95
Stella Huang (StellaHuang95) merged commit 03176cd into microsoft:main Aug 26, 2026
44 checks passed
@StellaHuang95
Stella Huang (StellaHuang95) deleted the copilot/pep723-uv-compat branch August 26, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-request Request for new features or functionality review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants