-
-
Notifications
You must be signed in to change notification settings - 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
base: master
Are you sure you want to change the base?
Conversation
| # 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_.]+") | ||
|
|
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?
Hatch uses the ruff formatter as code style.
* Sync to pypa/hatch#2037 * . --------- Co-authored-by: konstin <[email protected]>
| ) | ||
| else: | ||
| command = ['python', '-u', '-m', 'hatchling', 'build', '--target', target] | ||
| command = [sys.executable, '-u', '-m', 'hatchling', 'build', '--target', target] |
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.
Does this need to change to sys.executable?
| variant_props: list[str] | None = None, # noqa: ARG002 | ||
| variant_label: str | None = None, # noqa: ARG002 |
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.
If these are not used as part of the interface for other plugins these should be removed. And my understanding of variants is that these would only ever be applicable to the wheel implementation.
WheelNext & Wheel Variants
Caution
This is an an experimental feature currently being formalized as a PEP.
This is not an official feature of the Python Ecosystem & Standards.
This PR is part of the work being conducted by the WheelNext open-source initiative.
This PR introduces the feature of "Wheel Variant" into hatch & hatchling as a proof-of-concept.
Hopefully, this will give a good idea on:
How do "Wheel Variants" work ?
Wheel Variant is a proposed extension to the wheel specification designed to make platform-specific package distribution easier for package maintainers, and installation more smooth for end users. The key concepts are:
A Provider Plugin system, allowing vendors and communities to ship small, install-time packages that can detect system capabilities (e.g., CUDA version, CPU features).
A declarative metadata format for wheels to express their specific requirements (e.g.,
nvidia :: cuda_version_lower_bound :: 12.8). Yes, absolutely inspired by Python classifier format.A mechanism for installers to automatically run these plugins to match the user's system with the best-fitting variant wheel, simplifying the user experience to a familiar
[uv] pip install torch.We have carefully designed this system to ensure that installers unaware of variants will safely ignore them, maintaining backward compatibility with the existing ecosystem.
Links and Resources:
uvPR Details
--variant-propertyto allow users to build variant wheels with a given variant specifier. Example:variant.jsoninto the wheel, whenever the wheel is variant-enabled.TODOs
python -m build.cc @DEKHTIARJonathan, @warsaw