Skip to content

Parse wheel variant dependency markers - #23257

Merged
konsti-openai merged 1 commit into
mainfrom
konsti/parse-wheel-variant-marker
Nov 23, 2026
Merged

konsti-openai merged 1 commit into
mainfrom
konsti/parse-wheel-variant-marker

Conversation

@konstin

@konstin konstin commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Parse PEP 825's variant_label, variant_namespaces, variant_features,
and variant_properties in dependency specifiers. Validate set members with
the same component types as wheel metadata, ignore whitespace adjacent to
::, and reject the variables in environment selectors.

Use the same fallback for all dependencies, regardless of the declaring wheel.
Label equality and membership tests are false; their negations are true. For
example, even on a -null.whl, neither variant_label == 'null' nor
variant_label == '' matches, while variant_label != '' does. For ordering
comparisons, the label sorts after every compared string. The three variant
sets are empty, so 'nvidia' in variant_namespaces is false and
'nvidia' not in variant_namespaces is true.

The resolver resolves variant predicates before constructing forks.
Evaluation against the declaring wheel's actual variant metadata is deferred.

@konstin
konstin added this pull request to stack #23258 November 16, 2026 14:51
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from ecd584a to ccbf8b0 Compare November 16, 2026 14:57
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from ccbf8b0 to 511c8d9 Compare November 16, 2026 14:59
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch 2 times, most recently from 36da723 to e8f4905 Compare November 16, 2026 15:32
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from e8f4905 to 92202b7 Compare November 16, 2026 15:57
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from 92202b7 to 2abb1e7 Compare November 16, 2026 16:04
@konstin
konstin requested a review from zsol November 16, 2026 16:15
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from 2abb1e7 to 6cadfd4 Compare November 16, 2026 16:43
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from 6cadfd4 to bbbf81a Compare November 16, 2026 16:48
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from bbbf81a to 83e5e8d Compare November 17, 2026 08:07

@zsol zsol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I’m hesitant to land this on its own. Even if nobody uses variant labels yet, uv now accepts these markers and can silently resolve the wrong dependencies: a null-variant wheel resolves dependencies for variant_label == '' instead of variant_label == 'null'. I understand evaluation against the declaring wheel is deferred, but I think the two changes should land together, or uv should reject predicates it can’t evaluate correctly until then.

Some(VersionOrUrl::VersionSpecifier(_)) => {}
}

// Variant markers are unsupported in build-backend requirements.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the direct build check needs to use the same marker evaluation as build dependency resolution. With:

[build-system]
requires = ["uv_build>=0.13.0,<0.14.0; variant_label == ''"]
build-backend = "uv_build"

uv build --wheel --no-index succeeds with the bundled backend, but --force-pep517 fails because uv_build isn't installed. This check evaluates the label as '', while build dependency resolution treats the requirement as having no declaring wheel and disables it.

let pair = match key {
MarkerValueList::VariantNamespaces => {
CanonicalMarkerListPair::VariantNamespace(
VariantNamespace::from_str(&l_string).map_err(invalid_component)?,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

'NVIDIA' not in variant_namespaces should always be true, since no valid namespace can equal NVIDIA. Instead, this rejects the entire wheel’s metadata with Invalid variant namespace: NVIDIA. Is that intended? Sounds problematic to me

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.

I think we should reject invalid values, if they never enter the ecosystem it's better than having a silent failure mode where a query doesn't do what it appears to be doing.

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.

Another way to view it is that value we're testing against isn't a freeform string, but a DSL (with the ::) and we're enforcing the DSL's rules.

@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from 83e5e8d to d15d7d2 Compare November 17, 2026 13:37
Base automatically changed from konsti/parse-wheel-variant-marker-deserialization to main November 17, 2026 21:10
Parse PEP 825's `variant_label`, `variant_namespaces`, `variant_features`,
and `variant_properties` in dependency specifiers. Validate set members with
the same component types as wheel metadata, ignore whitespace adjacent to
`::`, and reject the variables in environment selectors.

Use the same fallback for all dependencies, regardless of the declaring wheel.
Label equality and membership tests are false; their negations are true. For
example, even on a `-null.whl`, neither `variant_label == 'null'` nor
`variant_label == ''` matches, while `variant_label != ''` does. For ordering
comparisons, the label sorts after every compared string. The three variant
sets are empty, so `'nvidia' in variant_namespaces` is false and
`'nvidia' not in variant_namespaces` is true.

The resolver resolves variant predicates before constructing forks.
Evaluation against the declaring wheel's actual variant metadata is deferred.
@konstin
konstin force-pushed the konsti/parse-wheel-variant-marker branch from d15d7d2 to d3279fc Compare November 17, 2026 21:10
@konsti-openai
konsti-openai merged commit b8f3516 into main Nov 23, 2026
69 checks passed
@konsti-openai
konsti-openai deleted the konsti/parse-wheel-variant-marker branch November 23, 2026 21:31
astral-automations-bot Bot pushed a commit to astral-sh/uv-dev that referenced this pull request Nov 23, 2026
konsti-openai pushed a commit that referenced this pull request Dec 1, 2026
Continues #23257, reverted in #23373. See the [original
review](#23257 (review)).

Parse PEP 825's `variant_label`, `variant_namespaces`,
`variant_features`, and `variant_properties` in named dependency
specifiers. Notably, we don't evaluate the markers yet, but uv won't
error (with or without preview) when observing them, allowing packages
to have wheel variants and variant information in `METADATA` even if uv
won't install those variants yet.

For now, `variant_label` is `''` everywhere, including on variant
wheels. This means `foo; variant_label == ''` always applies. The three
variant sets are empty, so `"nvidia" in variant_namespaces` is false and
`"nvidia" not in variant_namespaces` is true. Evaluation against the
declaring wheel's label and compatible properties is deferred.

The parser rejects ordered comparisons (`<`, `<=`, `>`, `>=`) on
`variant_label`. For a path or URL with a variant marker, require `name
@ <url>` so uv can apply overrides without building the source to
discover its name. The resolver resolves variant predicates before
constructing forks.

---------

Co-authored-by: konstin <[email protected]>

This branch was previously deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants