-
-
Couldn't load subscription status.
- Fork 348
Wheel Variant Experimental Support #2037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hcho3
wants to merge
18
commits into
pypa:master
Choose a base branch
from
wheelnext:wheel-variant-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c5bbb16
[WIP] Add variant support
hcho3 17ac308
Add variant support, wheel build functional
hcho3 302daa1
Python path
DEKHTIARJonathan 944ad69
Incorrect logic fixed. Explicitly block forbidden scenario
DEKHTIARJonathan c2ae650
[Null Variant] Made uniform
DEKHTIARJonathan acfff59
[VariantLib] constant file updated
DEKHTIARJonathan e51c72b
Adjustment to new Specs
DEKHTIARJonathan e14634a
Address review comment: Pass variant kwargs to all builders
hcho3 adfd0f9
Address various review comments
hcho3 68b905f
Add PEP517 config_settings interface
hcho3 8c27bd4
Variant Schema URL updated
DEKHTIARJonathan 88bb42f
Format variant support with ruff
konstin c93cd7e
Allow non-variant wheels to be built
konstin 99488c9
Only namespace in a mandatory default priority
konstin ad9d264
Better error message for missing variant information
konstin c7f4340
Support `plugin-use`
konstin 61469e5
Support `plugin-use` in VariantProviderConfig
konstin e349fd4
Support `config_settings` being `None`
konstin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # This file is copied from variantlib/variantlib/constants.py | ||
| # Do not edit this file directly, instead edit variantlib/variantlib/constants.py | ||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| from typing import Literal | ||
| from typing import TypedDict | ||
|
|
||
| VARIANT_LABEL_LENGTH = 16 | ||
| NULL_VARIANT_LABEL = "null" | ||
| CONFIG_FILENAME = "variants.toml" | ||
| VARIANT_DIST_INFO_FILENAME = "variant.json" | ||
|
|
||
| # Common variant info keys (used in pyproject.toml and variants.json) | ||
| VARIANT_INFO_DEFAULT_PRIO_KEY: Literal["default-priorities"] = "default-priorities" | ||
| VARIANT_INFO_FEATURE_KEY: Literal["feature"] = "feature" | ||
| VARIANT_INFO_NAMESPACE_KEY: Literal["namespace"] = "namespace" | ||
| VARIANT_INFO_PROPERTY_KEY: Literal["property"] = "property" | ||
| VARIANT_INFO_PROVIDER_DATA_KEY: Literal["providers"] = "providers" | ||
| VARIANT_INFO_PROVIDER_ENABLE_IF_KEY: Literal["enable-if"] = "enable-if" | ||
| VARIANT_INFO_PROVIDER_OPTIONAL_KEY: Literal["optional"] = "optional" | ||
| VARIANT_INFO_PROVIDER_PLUGIN_API_KEY: Literal["plugin-api"] = "plugin-api" | ||
| VARIANT_INFO_PROVIDER_PLUGIN_USE_KEY: Literal["plugin-use"] = "plugin-use" | ||
| VARIANT_INFO_PROVIDER_REQUIRES_KEY: Literal["requires"] = "requires" | ||
|
|
||
| PYPROJECT_TOML_TOP_KEY = "variant" | ||
|
|
||
| VARIANTS_JSON_SCHEMA_KEY: Literal["$schema"] = "$schema" | ||
| VARIANTS_JSON_SCHEMA_URL = "https://variants-schema.wheelnext.dev/v0.0.2.json" | ||
| VARIANTS_JSON_VARIANT_DATA_KEY: Literal["variants"] = "variants" | ||
|
|
||
| VALIDATION_VARIANT_LABEL_REGEX = re.compile(rf"[0-9a-z._]{{1,{VARIANT_LABEL_LENGTH}}}") | ||
|
|
||
| VALIDATION_NAMESPACE_REGEX = re.compile(r"[a-z0-9_]+") | ||
| VALIDATION_FEATURE_NAME_REGEX = re.compile(r"[a-z0-9_]+") | ||
| VALIDATION_VALUE_REGEX = re.compile(r"[a-z0-9_.]+") | ||
|
|
||
| VALIDATION_FEATURE_REGEX = re.compile( | ||
| rf""" | ||
| (?P<namespace>{VALIDATION_NAMESPACE_REGEX.pattern}) | ||
| \s* :: \s* | ||
| (?P<feature>{VALIDATION_FEATURE_NAME_REGEX.pattern}) | ||
| """, | ||
| re.VERBOSE, | ||
| ) | ||
|
|
||
| VALIDATION_PROPERTY_REGEX = re.compile( | ||
| rf""" | ||
| (?P<namespace>{VALIDATION_NAMESPACE_REGEX.pattern}) | ||
| \s* :: \s* | ||
| (?P<feature>{VALIDATION_FEATURE_NAME_REGEX.pattern}) | ||
| \s* :: \s* | ||
| (?P<value>{VALIDATION_VALUE_REGEX.pattern}) | ||
| """, | ||
| re.VERBOSE, | ||
| ) | ||
|
|
||
| VALIDATION_PROVIDER_ENABLE_IF_REGEX = re.compile(r"[\S ]+") | ||
| VALIDATION_PROVIDER_PLUGIN_API_REGEX = re.compile( | ||
| r""" | ||
| (?P<module> [\w.]+) | ||
| (?: \s* : \s* | ||
| (?P<attr> [\w.]+) | ||
| )? | ||
| """, | ||
| re.VERBOSE, | ||
| ) | ||
| VALIDATION_PROVIDER_REQUIRES_REGEX = re.compile(r"[\S ]+") | ||
|
|
||
|
|
||
| # VALIDATION_PYTHON_PACKAGE_NAME_REGEX = re.compile(r"[^\s-]+?") | ||
| # Per PEP 508: https://peps.python.org/pep-0508/#names | ||
| VALIDATION_PYTHON_PACKAGE_NAME_REGEX = re.compile( | ||
| r"[A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9]", re.IGNORECASE | ||
| ) | ||
| VALIDATION_WHEEL_NAME_REGEX = re.compile( | ||
| r"(?P<base_wheel_name> " # <base_wheel_name> group (without variant) | ||
| r" (?P<namever> " # "namever" group contains <name>-<ver> | ||
| r" (?P<name>[^\s-]+?) " # <name> | ||
| r" - (?P<ver>[^\s-]*?) " # "-" <ver> | ||
| r" ) " # close "namever" group | ||
| r" (?: - (?P<build>\d[^-]*?) )? " # optional "-" <build> | ||
| r" - (?P<pyver>[^\s-]+?) " # "-" <pyver> tag | ||
| r" - (?P<abi>[^\s-]+?) " # "-" <abi> tag | ||
| r" - (?P<plat>[^\s-]+?) " # "-" <plat> tag | ||
| r") " # end of <base_wheel_name> group | ||
| r"(?: - (?P<variant_label> " # optional <variant_label> | ||
| rf" {VALIDATION_VARIANT_LABEL_REGEX.pattern}" | ||
| r" ) " | ||
| r")? " | ||
| r"\.whl " # ".whl" suffix | ||
| r" ", | ||
| re.VERBOSE, | ||
| ) | ||
|
|
||
|
|
||
| # ======================== Json TypedDict for the JSON format ======================== # | ||
|
|
||
| # NOTE: Unfortunately, it is not possible as of today to use variables in the definition | ||
| # of TypedDict. Similarly also impossible to use the normal "class format" if a | ||
| # key uses the characted `-`. | ||
| # | ||
| # For all these reasons and easier future maintenance - these classes have been | ||
| # added to this file instead of a more "format definition" file. | ||
|
|
||
|
|
||
| class PriorityJsonDict(TypedDict, total=False): | ||
| namespace: list[str] | ||
| feature: dict[str, list[str]] | ||
| property: dict[str, dict[str, list[str]]] | ||
|
|
||
|
|
||
| ProviderPluginJsonDict = TypedDict( | ||
| "ProviderPluginJsonDict", | ||
| { | ||
| "plugin-api": str, | ||
| "requires": list[str], | ||
| "enable-if": str, | ||
| "optional": bool, | ||
| "plugin-use": Literal["all", "build", "none"], | ||
| }, | ||
| total=False, | ||
| ) | ||
|
|
||
| VariantInfoJsonDict = dict[str, dict[str, list[str]]] | ||
|
|
||
|
|
||
| VariantsJsonDict = TypedDict( | ||
| "VariantsJsonDict", | ||
| { | ||
| "$schema": str, | ||
| "default-priorities": PriorityJsonDict, | ||
| "providers": dict[str, ProviderPluginJsonDict], | ||
| "variants": dict[str, VariantInfoJsonDict], | ||
| }, | ||
| total=False, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use variantlib itself to obtain these?