Skip to content

Commit c6aa3d3

Browse files
committed
Most of it is done
Signed-off-by: Michał Górny <mgorny@quansight.com>
1 parent 0316086 commit c6aa3d3

File tree

1 file changed

+74
-22
lines changed

1 file changed

+74
-22
lines changed

peps/pep-9999.rst

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ Post-History:
2121
Abstract
2222
========
2323

24-
[A short (~200 word) description of the technical issue being addressed.]
24+
This PEP proposes variant wheels, an extension to
25+
:doc:`packaging:specifications/binary-distribution-format` that permits
26+
building multiple variants of the same package while embedding arbitrary
27+
compatibility data. The specific properties are stored inside the wheel,
28+
and expressed via a human-readable variant label in the filename, which
29+
is then mapped to the actual properties via a separately hosted JSON
30+
mapping. This aims to make ``{tool} install {package}`` capable of
31+
selecting the most appropriate variant of packages such as PyTorch,
32+
where additional compatibility dimensions such as GPU support need to be
33+
accounted for.
2534

2635

2736
Motivation
@@ -560,8 +569,8 @@ If there is a ``[packages.variants-json]`` section, the tool SHOULD
560569
resolve variants to select the best wheel file.
561570

562571

563-
Suggested implementation logic for installers (non-normative)
564-
-------------------------------------------------------------
572+
Suggested implementation logic for tools (non-normative)
573+
--------------------------------------------------------
565574

566575
Installing a package from an index
567576
''''''''''''''''''''''''''''''''''
@@ -614,6 +623,37 @@ to:
614623
5. Verify the wheel compatibility via compatible properties.
615624

616625

626+
Publishing variant wheels on an index
627+
'''''''''''''''''''''''''''''''''''''
628+
629+
Variant wheels are uploaded to an index just like regular wheels.
630+
There are two possible approaches to publishing the index-level
631+
``{name}-{version}-variants.json`` file for every package version:
632+
it can either be prepared and uploaded by the user, or it can be
633+
generated automatically by the index.
634+
635+
The file should not be changed once it is published, as clients may have
636+
already cached it or locked to the existing hash. For this reason, if
637+
the index is responsible for generating the file, it should use some
638+
mechanism to defer publishing it until the release is fully uploaded
639+
(for example, :pep:`694`).
640+
641+
To generate the ``{name}-{version}-variants.json`` file:
642+
643+
1. For the first variant wheel for a given package version, copy the
644+
data from its ``*.dist-info/variant.json`` file.
645+
2. For subsequent wheels, merge the data from their
646+
``*.dist-info/variant.json`` files into the existing data:
647+
648+
- disjoint keys of ``variants`` dictionary are merged together
649+
- common keys of these dictionaries must have exactly the same value
650+
- ``default-priorities.namespace`` list can be replaced if the new
651+
value starts with the old value
652+
- ``default-priorities.feature`` and ``default-priorities.value``
653+
keys can be added if they were not present in the previous
654+
``default-priorities.namespace`` value
655+
656+
617657
Rationale
618658
=========
619659

@@ -709,7 +749,14 @@ or dependencies specific to variant wheels from the non-variant wheel.
709749
Security Implications
710750
=====================
711751

712-
[How could a malicious user take advantage of this new feature?]
752+
The presence of variant wheels may lead to some of the variants being
753+
subject to less scrutiny than others, and as such becoming easier attack
754+
targets. Particularly, once variant wheel support becomes commonplace,
755+
the non-variant wheels for some packages may be only consumed by users
756+
with outdated tools. However, such attacks assume that the package
757+
publishing workflow is already compromised, in which case more plausible
758+
attack vectors are available, for example via modifying compiled
759+
extensions.
713760

714761

715762
How to Teach This
@@ -721,7 +768,13 @@ How to Teach This
721768
Reference Implementation
722769
========================
723770

724-
[Link to any existing implementation and details about its state, e.g. proof-of-concept.]
771+
The `variantlib <https://github.com/wheelnext/variantlib>`__ project
772+
contains a reference implementation of a complete variant wheel
773+
solution. It is compliant with this PEP, but also goes beyond it,
774+
providing example solutions to `open issues`_.
775+
776+
A client for installing variant wheels is implemented in a
777+
`uv branch <https://github.com/astral-sh/uv/pull/12203>`__.
725778

726779

727780
Rejected Ideas
@@ -760,35 +813,34 @@ would be incorrectly deemed compatible because of the
760813
Open Issues
761814
===========
762815

763-
[Any points that are still being decided/discussed.]
816+
The following problems are deferred to subsequent PEPs:
817+
818+
- governance of variant namespaces
819+
- determining which variant properties are compatible with the system
820+
- building variant wheels
764821

765822

766823
Acknowledgements
767824
================
768825

769-
[Thank anyone who has helped with the PEP.]
770-
771-
772-
Footnotes
773-
=========
826+
This work would not have been possible without the contributions and
827+
feedback of many people in the Python packaging community. In
828+
particular, we would like to credit the following individuals for their
829+
help in shaping this PEP (in alphabetical order):
774830

775-
[A collection of footnotes cited in the PEP, and a place to list non-inline hyperlink targets.]
831+
Alban Desmaison, Bradley Dice, Chris Gottbrath, Dmitry Rogozhkin,
832+
Emma Smith, Geoffrey Thomas, Henry Schreiner, Jeff Daily, Jeremy Tanner,
833+
Jithun Nair, Keith Kraus, Leo Fang, Mike McCarty, Nikita Shulga,
834+
Paul Ganssle, Philip Hyunsu Cho, Robert Maynard, Vyas Ramasubramani,
835+
and Zanie Blue.
776836

777837

778838
Change History
779839
==============
780840

781-
[A summary of major changes the PEP has undergone. Whenever you update the
782-
``Post-History``, add a new bullet item in newest-first (i.e. reverse
783-
chronological) order, using the same ``DD-MMM-YYYY`` format, with sub-bullets
784-
summarizing the changes. You can use the same link for the date bullet as you
785-
do in the ``Post-History`` addition.]
786-
787-
788-
References
789-
==========
841+
- TBD
790842

791-
.. _uv: https://pypi.org/project/uv/
843+
- Initial version, split from :pep:`817` draft.
792844

793845

794846
Copyright

0 commit comments

Comments
 (0)