{"slug": "an-introduction-to-wheel-variants-for-python-package-maintainers", "title": "An introduction to wheel variants for Python package maintainers", "summary": "PEPs 817, 825, and 850 propose extending the Python wheel format with \"wheel variants\" so installers can select builds based on additional compatibility properties such as GPU architecture and CPU instruction set extensions, according to the proposal write-up. The current platform tag cannot express GPU requirements — torch 2.14.1 on PyPI supports CUDA 13.0 and architectures sm_75, sm_80, sm_86, sm_90, sm_100 and sm_120, but nothing in the package records this — nor SIMD extensions such as those enabled by clang -march=x86-64-v3, which can crash at runtime on older CPUs. Under the proposal, maintainers publish multiple builds of the same release with short free-form variant labels, letting a user install with `uv add torch` instead of manually selecting an index such as https://download.pytorch.org/whl/cu130.", "body_md": "PEPs [817](https://peps.python.org/pep-0817/), [825](https://peps.python.org/pep-0825/), and\n[850](https://peps.python.org/pep-0850/) propose extending the Python wheel format with **wheel\nvariants**, which would let installers consider additional compatibility properties, like GPU\narchitecture or CPU instruction set extensions, when choosing a build.\n\nWhat does this mean for your project? This post walks through how to use wheel variants to distribute builds of the same release for different environments.\n\n## Before and after wheel variants [#](#before-and-after-wheel-variants)\n\nHistorically, Python has represented wheel compatibility in the platform tag of the wheel filename.\nFor example, the filename `numpy-2.0.0-cp314-cp314-manylinux2014_x86_64.whl` states that the wheel\nworks with any 64-bit x86 processor.\n\nThis format, however, presents two main gaps:\n\n1. \n**It does not capture GPU and TPU requirements.** We know that `torch 2.14.1` on PyPI is compatible with CUDA 13.0 and the architectures`sm_75` ,`sm_80` ,`sm_86` ,`sm_90` ,`sm_100` and`sm_120` , but there’s nothing in the package that\nspecifies this compatibility.On the PyTorch index, the filename for 2.14.1 is `torch-2.14.1+cu130-cp314-cp314-manylinux_2_28_x86_64.whl` , which includes the CUDA version the\nwheel was built for (13.0), but still doesn’t list the GPU architectures the wheel supports. Even\nso, this information isn’t standardized across filenames, so installers cannot use these fields\nto check compatibility.\n2. \n**It does not capture CPU extensions.** SIMD instructions can speed up C and Rust code by letting a CPU process several values at once. Developers can invoke them manually, or let the compiler generate them with flags such as `clang -march=x86-64-v3` . A wheel’s platform tag\nidentifies the CPU architecture (here, a 64-bit x86 processor), but it doesn’t specify the\ninstruction set extensions that the build requires. This makes it difficult for projects to\ndistribute wheels that require newer SIMD instructions, which can crash at runtime on older,\nincompatible CPUs.\n\nInstalling machine learning packages for the correct GPU is one of the most commonly raised uv issues. Currently, a user is responsible for selecting the build that is compatible with their desired CPU and architecture, which is difficult and error-prone.\n\nSuppose a user wants to install PyTorch 2.14.1 on a Linux machine with an NVIDIA H100. To choose a\ncompatible build of PyTorch 2.14.1, the user checks that their driver supports CUDA 13.0 and that\nthe build supports their H100 (`sm_90`). They would then have to manually select the CUDA 13.0 build\nfrom the PyTorch index:\n\n```\nuv add 'torch==2.14.1' --index pytorch=https://download.pytorch.org/whl/cu130\n```\n\nIf your project targets multiple GPUs, you also have to manually configure uv to handle conflicting\nPyTorch index URLs, which\n[we cover in a dedicated docs page](https://docs.astral.sh/uv/guides/integration/pytorch/).\n\nWith wheel variants, maintainers can publish multiple builds of the same release, and the installer can automatically select a compatible wheel based on the user’s detected environment.\n\nInstalling `torch` across any environment becomes much simpler:\n\n```\nuv add torch\n```\n\nSo, how do maintainers implement variants?\n\n## Implementing wheel variants [#](#implementing-wheel-variants)\n\n### Identify different builds [#](#identify-different-builds)\n\nBy extending the wheel format, wheel variants let maintainers record additional compatibility data in binary packages. This enables a project to publish several wheels with different compatibility tags for the same package version.\n\nThe first step in implementing wheel variants is deciding which builds of your package to offer\nbased on distinguishing characteristics. For each build variant you want to support, pick a short,\nfree-form **variant label**. A variant label can describe one or more of these distinguishing build\nrequirements.\n\nFor example, you may want to offer two builds of the same PyTorch release. Both require CUDA 13.0\nsupport, but one also uses AVX-512 Foundation instructions; you might select `cu130` and\n`cu130avx512` for the variant labels. Each label identifies a **wheel variant**. The **variant\nwheel** for `cu130` is the `.whl` file whose name ends in `-cu130.whl`.\n\n```\ntorch-2.14.1-cp314-cp314-manylinux_2_28_x86_64-cu130.whl\ntorch-2.14.1-cp314-cp314-manylinux_2_28_x86_64-cu130avx512.whl\n```\n\n### Identify relevant providers [#](#identify-relevant-providers)\n\nOnce you know how your builds will differ, identify the **providers** that describe those\ndifferences.\n\nA **provider** defines a set of properties that maintainers can use to describe a wheel’s\nrequirements. Providers group these properties into categories called **namespaces**.\n\nNamespaces generally can be any build characteristic that helps the installer choose which wheel to install, including:\n\n- **Hardware requirements** , like the CPU instruction set extensions in`x86_64` .\n- **Library choices** , such as OpenBLAS.\n- **Binary compatibility with a dependency** , like a`flash-attn` wheel built for the PyTorch 2.8\nseries, even though the same release can be built against other PyTorch versions.\n\nFor example, the NVIDIA provider governs the `nvidia` namespace, which includes features that\nspecify CUDA driver compatibility and GPU architecture.\n\nInstallers (like uv) may bundle a small set of trusted, essential providers by default. If the\ninstaller doesn’t already trust a provider that you want to use, you must explicitly authorize the\ninstaller to execute that provider’s code. We’ve already implemented some preliminary providers in\nthe [WheelNext repository](https://github.com/wheelnext/).\n\nEach provider defines and maintains the properties and values it recognizes. The\n[NVIDIA provider](https://github.com/wheelnext/nvidia-variant-provider#methods) exposes\n`get_supported_configs()` to list the features and values in the `nvidia` namespace that the host\nmachine supports:\n\n```\nconfigs = plugin.get_supported_configs()\n# Returns:\n# [\n#   VariantFeatureConfig(name='cuda_version_lower_bound', values=['12.8', '12.7', ...]),\n#   VariantFeatureConfig(name='cuda_version_upper_bound', values=[..., '13.0', '12.9']),\n#   VariantFeatureConfig(name='sm_arch', values=['95_real', ..., '90_real', '90_virtual']),\n# ]\n```\n\nThere are a few types of providers, but the main kind of provider is a provider package, with\nfunctions that the installer calls in an isolated virtual environment, similar to build backends.\nThe NVIDIA provider is implemented as a Python plugin and distributed in the\n`nvidia-variant-provider` package.\n\nFor our `cu130avx512` wheel, we’ll use the NVIDIA provider to describe CUDA and GPU requirements,\nand the `x86-64` provider to describe the AVX-512 Foundation requirement.\n\n### Describe each build [#](#describe-each-build)\n\nEach **variant wheel** has a file `{name}-{version}.dist-info/variant.json` that describes the\nrequirements of its build. The package index collects these descriptions in\n`{name}-{version}-variants.json`, which the installer uses to compare variants before downloading a\nwheel.\n\nIn `variant.json`, the variant wheel will enumerate its **variant properties**. Throughout the post,\nwe’ll write variant properties in the shape `namespace :: feature :: value`. In `variant.json`,\nproperties are written as:\n\n```\n\"namespace\": { \"feature\": [\"value\"] }\n```\n\nA **variant namespace** groups related features governed by a provider. A **feature** names a\ncharacteristic within that group, and a **value** specifies the build’s requirement for that\ncharacteristic.\n\nIn our `cu130` and `cu130avx512` example, both builds target the same GPU architectures, but the\n`cu130avx512` wheel also declares the CPU extension it requires. Its `providers` and `variants`\nsections of its `variant.json` might look like:\n\n```\n{\n  \"providers\": {\n    \"nvidia\": {\n      \"requires\": [\"nvidia-variant-provider\"],\n      \"plugin-api\": \"nvidia_variant_provider.plugin:NvidiaVariantPlugin\"\n    },\n    \"x86_64\": { \"requires\": [\"x86-64-variant-provider\"] }\n  },\n  \"variants\": {\n    \"cu130avx512\": {\n      \"nvidia\": {\n        \"cuda_version_lower_bound\": [\"13.0\"],\n        \"sm_arch\": [\"80_real\", \"90_real\"]\n      },\n      \"x86_64\": { \"avx512f\": [\"on\"] }\n    }\n  }\n}\n```\n\nHere, the `providers` section identifies the plugin for each namespace. The `variants` section uses\nthese namespaces to describe the requirements of the `cu130avx512` wheel.\n\nToday, maintainers can add the variant label and metadata themselves or use an experimental tool\nlike `variant-repack`. We’re working to finalize the workflow outlined in PEP 817, where you declare\nproviders and variants in `pyproject.toml`, and your build tool writes the corresponding\n`variant.json` into each wheel.\n\n### Declare variant-specific dependencies [#](#declare-variant-specific-dependencies)\n\nYou can also use **variant markers** to specify dependencies in `.dist-info/METADATA` which are\nconditional on particular wheel variants. These markers evaluate based on the wheel the installer\nselects.\n\nThere are four available variant markers: `variant_label`, `variant_namespaces`, `variant_features`\nand `variant_properties`. While the `variant_label` is a string value and uses `==` and `!=`\noperators, the other three markers are sets of values and support the `in` and `not in` operators.\n\nSuppose you have a package with one GPU and one CPU build per version. The GPU build requires\n`nvidia-util`, while the CPU build can run without it. A **variant marker** enables you to declare\nthe `nvidia-util` dependency for only GPU builds. The associated dependency declaration in\n`METADATA` would look like:\n\n```\nRequires-Dist: nvidia-util>=1,<2; \"nvidia\" in variant_namespaces\n```\n\nThis example means: “install `nvidia-util` version 1.x only if the selected wheel declares\nproperties in the `nvidia` namespace.”\n\nWhile you can use a marker to decide whether a build needs a package, we recommend against using markers to choose which version of a package each CUDA build requires. For example:\n\n```\nnvidia-cuda-support==13.2; \"nvidia :: cuda_version_lower_bound :: 13.2\" in variant_properties\nnvidia-cuda-support==13.3; \"nvidia :: cuda_version_lower_bound :: 13.3\" in variant_properties\n```\n\nSome universal resolvers may not support choosing a dependency’s version based on which wheel is selected, meaning they may fail to generate a lockfile.\n\nInstead, we recommend using variants across the stack. The maintainer would publish two wheels for\nv1.0 of `nvidia-cuda-support`, one for CUDA 13.2, and one for CUDA 13.3, and leave the installer to\ndetermine which to install based on variant metadata. Both CUDA builds of your package would then\ndeclare the same requirement:\n\n```\nnvidia-cuda-support==1.0\n```\n\n## How an installer chooses a wheel [#](#how-an-installer-chooses-a-wheel)\n\n### Compatibility [#](#compatibility)\n\nWhen a user installs your package, the installer first checks the wheel’s Python, ABI, and platform\ntags. For wheels that match these requirements, the installer will then compare the **variant\nproperties** declared by the wheel with the values the user’s machine supports.\n\nFor a wheel to be compatible, the host must support at least one value for every feature the wheel declares. Suppose the user has an NVIDIA H100 and a driver that supports CUDA 13.0:\n\nThe `cu130` wheel requires…\n\n```\nnvidia :: cuda_version_lower_bound :: 13.0\nnvidia :: sm_arch :: 80_real\nnvidia :: sm_arch :: 90_real\n```\n\nand the host supports…\n\n```\nnvidia :: cuda_version_lower_bound :: 13.0\nnvidia :: cuda_version_lower_bound :: 12.8\nnvidia :: cuda_version_lower_bound :: 12.6\nnvidia :: cuda_version_lower_bound :: 12.4\nnvidia :: sm_arch :: 90_real\nnvidia :: sm_arch :: 90_virtual\n```\n\nThe features `nvidia :: sm_arch` and `nvidia :: cuda_version_lower_bound` are satisfied by the\nmatches on our `cu130` wheel’s values of `90_real` and `13.0`, respectively.\n\nIf the CPU also supported AVX-512 instructions, then both `cu130` and `cu130avx512` would be\ncompatible with the host. How would the installer choose between these two wheels?\n\n### Ordering [#](#ordering)\n\nWhen more than one wheel is compatible, the installer ranks wheels by their matching variant properties. Maintainers can influence which wheel is selected by choosing which namespaces take priority.\n\nThe installer ranks variants first by namespace, then by feature, then by value. A maintainer\ndefines namespace rankings based on the order they appear in `variant.json`, but rankings of\nfeatures or values are determined by the provider.\n\nIf two wheels have the same highest-priority match, the installer will identify the second-best match, and so on. If all wheels rank equally on variant properties, then the platform tag will be considered.\n\nIn our example, if the maintainer lists `nvidia` before `x86_64` in `default_priorities.namespace`,\nthe installer compares NVIDIA matches first.\n\n```\n{\n  \"$schema\": \"...\",\n  \"default-priorities\": {\n    \"namespace\": [\"nvidia\", \"x86_64\"]\n  },\n  \"providers\": {\n    \"nvidia\": {\n      \"requires\": [\"nvidia-variant-provider\"],\n      \"plugin-api\": \"nvidia_variant_provider.plugin:NvidiaVariantPlugin\"\n    },\n    \"x86_64\": { \"requires\": [\"x86-64-variant-provider\"] }\n  },\n  \"variants\": {\n    \"cu130\": {\n      \"nvidia\": { \"cuda_version_lower_bound\": [\"13.0\"], \"sm_arch\": [\"80_real\", \"90_real\"] }\n    },\n    \"cu130avx512\": {\n      \"nvidia\": { \"cuda_version_lower_bound\": [\"13.0\"], \"sm_arch\": [\"80_real\", \"90_real\"] },\n      \"x86_64\": { \"avx512f\": [\"on\"] }\n    }\n  }\n}\n```\n\nBoth `cu130` and `cu130avx512` wheels match on CUDA `13.0` and GPU architecture `90_real`, so their\nNVIDIA properties tie. The installer then compares their CPU properties and selects the\n`cu130avx512` wheel due to its additional match of `x86_64 :: avx512f :: on`.\n\n## Up next [#](#up-next)\n\nThe variant format described in this post has been provisionally accepted in PEP 825, with the provider implementation (PEP 850) still in draft.\n\nYou can try uv’s experimental wheel selection today with the `wheel-variants` preview feature\nenabled in uv version 0.13.8 and above. Currently, you can test preview functionality with packages\nfrom the public [WheelNext test index](https://wheelnext.github.io/variants-index/v0.2.0/); we’re\nworking on a standard way to build variant wheels and publish them on PyPI. If there’s something you\nneed in uv to adopt variants,\n[let us know](https://github.com/astral-sh/uv/issues/new?template=2_feature_request.yaml)!\n\nIf you’re considering implementing wheel variants for your package, we’d love to hear how you’d use them and what the proposed standards might be missing.", "url": "https://wpnews.pro/news/an-introduction-to-wheel-variants-for-python-package-maintainers", "canonical_source": "https://astral.sh/blog/wheel-variants-for-maintainers", "published_at": "2026-11-30 22:26:30+00:00", "updated_at": "2026-11-30 22:45:25.533483+00:00", "lang": "en", "topics": ["developer-tools", "ai-infrastructure", "ai-tools"], "entities": ["Python", "uv", "PyTorch", "NVIDIA H100", "CUDA 13.0", "PEP 817", "PEP 825", "PEP 850"], "also_reported_by": [], "takeaway": "Wheel variants let maintainers ship multiple builds of one release tagged with free-form variant labels for GPU architecture or CPU SIMD level, so installers can pick a compatible wheel automatically instead of users hand-selecting an index like cu130.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/an-introduction-to-wheel-variants-for-python-package-maintainers", "markdown": "https://wpnews.pro/news/an-introduction-to-wheel-variants-for-python-package-maintainers.md", "text": "https://wpnews.pro/news/an-introduction-to-wheel-variants-for-python-package-maintainers.txt", "jsonld": "https://wpnews.pro/news/an-introduction-to-wheel-variants-for-python-package-maintainers.jsonld"}}