Repository navigation
Parse wheel variant dependency markers - #23257
Conversation
ecd584a to
ccbf8b0
Compare
ccbf8b0 to
511c8d9
Compare
36da723 to
e8f4905
Compare
e8f4905 to
92202b7
Compare
92202b7 to
2abb1e7
Compare
2abb1e7 to
6cadfd4
Compare
6cadfd4 to
bbbf81a
Compare
bbbf81a to
83e5e8d
Compare
zsol
left a comment
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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)?, |
There was a problem hiding this comment.
'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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
83e5e8d to
d15d7d2
Compare
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.
d15d7d2 to
d3279fc
Compare
Reverts astral-sh#23257, which was accidentally merged.
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]>
Parse PEP 825's
variant_label,variant_namespaces,variant_features,and
variant_propertiesin dependency specifiers. Validate set members withthe 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, neithervariant_label == 'null'norvariant_label == ''matches, whilevariant_label != ''does. For orderingcomparisons, the label sorts after every compared string. The three variant
sets are empty, so
'nvidia' in variant_namespacesis false and'nvidia' not in variant_namespacesis true.The resolver resolves variant predicates before constructing forks.
Evaluation against the declaring wheel's actual variant metadata is deferred.