Skip to content

Export selectable extras and groups in pylock.toml - #22118

Draft
konstin wants to merge 3 commits into
konsti/share-lock-root-lookupfrom
konsti/pylock-selectable-extras
Draft

konstin wants to merge 3 commits into
konsti/share-lock-root-lookupfrom
konsti/pylock-selectable-extras

Conversation

@konstin

@konstin konstin commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

PEP 751 allows extras and dependency groups to be selected when installing a lockfile. Existing pylock exports fix those selections at export time.

Add uv export --format pylock.toml --multi-use to retain selectable extras and dependency groups in the exported file, including their transitive dependencies. The project's selected dependency groups are included by default and can be adjusted with group flags. PEP 751 has no default-extras field, so extras must be selected at installation time; --multi-use cannot be combined with --extra or --all-extras. The existing --all-extras option keeps its single-use export behavior.

Multi-use exports are limited to one project and reject declared conflicts, negative extra markers, group-specific Python requirements, and workspace-root dependencies or groups. With a hand-written frozen lock, a literal extra name that matches uv's internal name for a conflict can cause a dependency to be omitted. Re-locking a project with equivalent wheel metadata did not reproduce the omission.

Comment thread crates/uv-cli/src/lib.rs
#[arg(long, conflicts_with_all = [
"batch", "script", "all_packages", "extra", "all_extras", "no_extra", "no_all_extras",
"only_group", "only_dev",
])]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ideally this would have been the default, but there's not default extras in PEP 751 (cause there's no way to deselect extras in standards either), so we keep this a separate path.

Name to be bikeshed, I don't love this one. "universal" would be great but that's already taken.

@astral-sh-bot

astral-sh-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the main base revision.

  • Added tests: 7
  • Removed tests: 0
  • Changed suites: 2
uv-lock::pylock_extras: +5 / -0

Added:

  • uv-lock::pylock_extras::rejects_conflicts
  • uv-lock::pylock_extras::rejects_group_python_requirement
  • uv-lock::pylock_extras::rejects_missing_group_metadata
  • uv-lock::pylock_extras::rejects_negative_extra_marker
  • uv-lock::pylock_extras::selectable_extras_and_groups

Removed: none

uv::project: +2 / -0

Added:

  • uv::project::export::pep_751_multi_use
  • uv::project::export::pep_751_multi_use_invalid_format_does_not_lock

Removed: none

@konstin
konstin force-pushed the konsti/pylock-selectable-extras branch from 741b5ae to 2d64321 Compare October 12, 2026 08:51
@konstin
konstin force-pushed the konsti/pylock-selectable-extras branch from 2d64321 to 6181d6a Compare October 12, 2026 09:23
@codspeed

codspeed Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 7 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 89 untouched benchmarks
⏩ 84 skipped benchmarks1


Comparing konsti/pylock-selectable-extras (ef2411f) with konsti/share-lock-root-lookup (39e8e91)

Open in CodSpeed

Footnotes

  1. 84 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@konstin
konstin force-pushed the konsti/pylock-selectable-extras branch from 4759b1c to 84ea9ce Compare October 19, 2026 13:17
@konstin
konstin force-pushed the konsti/pylock-selectable-extras branch from 84ea9ce to 18a52f0 Compare November 17, 2026 08:22
@konstin konstin added area:lock Related to universal resolution and locking enhancement New feature or improvement to existing functionality labels Nov 30, 2026
@konstin
konstin force-pushed the konsti/pylock-selectable-extras branch from 18a52f0 to 1474401 Compare November 30, 2026 19:37
Seed export reachability with PEP 751 selection markers so transitive dependencies inherit the conditions under which they are needed. Use a separate synthetic group for the default selection, leaving every project group independently selectable.

Reject unsupported inputs in the library before returning a lockfile. Existing callers still select extras and groups at export time.
Reject incompatible formats before locking. Verify that a lock generated from local wheels can be exported once and synced with different selections, even if a project group uses the synthetic default name.
@konstin
konstin force-pushed the konsti/pylock-selectable-extras branch from 1474401 to ef2411f Compare November 30, 2026 19:39
@konstin
konstin changed the base branch from main to konsti/share-lock-root-lookup November 30, 2026 19:39

This branch was previously deployed

1 inactive (outdated) deployment
automations — 18a52f01 Deployed Nov 17, 2026 by konstin via review | security / security review #54027
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:lock Related to universal resolution and locking enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant