@@ -321,6 +321,9 @@ or they may carefully merge their values, provided that no conflicting
321321information is introduced, and the resolution results within a subset of
322322variants do not change.
323323
324+ This file SHOULD NOT be considered immutable and MAY be updated in a
325+ backward compatible way at any point (e.g. when adding a new variant).
326+
324327Variant indexes MAY elect to either auto-generate the file from the
325328uploaded variant wheels or allow the user to manually generate it
326329themselves and upload it to the index.
@@ -631,52 +634,67 @@ Variant wheels can be listed in ``pylock.toml`` file in the same manner
631634as wheels with different Platform compatibility tags: either all variant
632635(and non-variant) wheels can be listed, or a subset of them.
633636
634- A new ``[packages.variants-json] `` subtable is added to the file, to
635- permit locking the ``{name}-{version}-variants.json `` file to a specific
636- hash. If variant wheels are listed for a given package, the tool SHOULD
637- lock this file as well.
637+ A new ``[packages.variants-json] `` subtable is added to the file. It
638+ MUST inline the contents of the `index-level metadata `_ file, converting
639+ the JSON structure into the respective TOML types. The ``$schema `` key
640+ MUST be preserved to facilitate versioning. The tools MAY remove keys
641+ that are not relevant to variant wheels present in ``pylock.toml ``.
638642
639643If variant wheels are listed, the tool SHOULD resolve variants to select
640644the best wheel file.
641645
642- The proposed text for :doc: `packaging:specifications/pylock-toml `
643- follows:
644646
645- .. code :: rst
647+ Proposed specification update
648+ '''''''''''''''''''''''''''''
646649
647- .. _pylock-packages-variants-json:
650+ The proposed text for :doc: `packaging:specifications/pylock-toml `
651+ follows:
648652
649- ``[packages.variants-json ]``
650- ----------------------------
653+ ``[packages.variant_json ] ``
654+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
651655
652- - **Type**: table
653- - **Required?**: no; requires that :ref:`pylock-packages-wheels` is used,
654- mutually-exclusive with :ref:`pylock-packages-vcs`,
655- :ref:`pylock-packages-directory`, and :ref:`pylock-packages-archive`.
656- - **Inspiration**: uv_
657- - The URL or path to the ``variants.json`` file.
658- - Only used if the project uses :ref:`wheel variants <wheel-variants>`.
656+ - **Type **: table
657+ - **Required? **: no
658+ - **Functions **:
659659
660- .. _pylock-packages-variants-json-url:
660+ - Inline variant selection metadata for the package.
661+ - The structure of this table MUST conform to the JSON Schema.
662+ - Tools that support variant-aware resolution MUST validate this table
663+ against the referenced schema.
664+ - Tools that do not support variant-aware resolution MAY ignore this table
665+ but SHOULD preserve it when rewriting the lock file.
661666
662- ``packages.variants-json.url``
663- ''''''''''''''''''''''''''''''
664667
665- See :ref:`pylock-packages-archive-url`.
668+ Example
669+ '''''''
666670
667- .. _pylock-packages-variants-json-path:
671+ .. code :: toml
668672
669- ``packages.variants-json.path``
670- '''''''''''''''''''''''''''''''
673+ lock-version = "1.0"
674+ created-by = "uv"
675+ requires-python = ">=3.14"
671676
672- See :ref:`pylock-packages-archive-path`.
677+ [[packages]]
678+ name = "numpy"
679+ version = "2.3.4"
680+ index = "https://pypi.anaconda.org/mgorny/simple"
681+ wheels = [
682+ { url = "https://pypi.anaconda.org/mgorny/simple/numpy/2.3.4/numpy-2.3.4-cp314-cp314-linux_x86_64-openblas.whl", hashes = {} },
683+ { url = "https://pypi.anaconda.org/mgorny/simple/numpy/2.3.4/numpy-2.3.4-cp314-cp314-linux_x86_64-x8664v4_mkl.whl", hashes = {} },
684+ { url = "https://pypi.anaconda.org/mgorny/simple/numpy/2.3.4/numpy-2.3.4-cp314-cp314-macosx_13_0_x86_64-accelerate.whl", hashes = {} },
685+ { url = "https://pypi.anaconda.org/mgorny/simple/numpy/2.3.4/numpy-2.3.4-cp314-cp314-macosx_13_0_x86_64-openblas.whl", hashes = {} },
686+ ]
673687
674- .. _pylock-packages-variants-json-hashes:
688+ [packages.variant_json]
689+ "$schema" = "https://variants-schema.wheelnext.dev/peps/825/v0.1.0.json"
675690
676- `` packages.variants-json.hashes``
677- '''''''''''''''''''''''''''''''''
691+ [ packages.variant_json.default-priorities]
692+ namespace = [ "x86_64", "aarch64", "blas_lapack" ]
678693
679- See :ref:`pylock-packages-archive-hashes`.
694+ [packages.variant_json.variants]
695+ null = { }
696+ x8664v3_openblas = { "blas_lapack" = { "library" = ["openblas"]}, "x86_64" = { "level" = ["v3"]} }
697+ x8664v4_mkl = { "blas_lapack" = { "library" = ["mkl"]}, "x86_64" = { "level" = ["v4"]} }
680698
681699
682700 Suggested implementation logic for tools (non-normative)
@@ -742,9 +760,7 @@ There are two possible approaches to publishing the index-level
742760it can either be prepared and uploaded by the user, or it can be
743761generated automatically by the index.
744762
745- The file should not be changed once it is published, as clients may have
746- already cached it or locked to the existing hash. For this reason, if
747- the index is responsible for generating the file, it should use some
763+ If the index is responsible for generating the file, it should use some
748764mechanism to defer publishing it until the release is fully uploaded
749765(for example, :pep: `694 `).
750766
@@ -813,6 +829,13 @@ wheels being unsupported altogether. For example, PyTorch could provide
813829a much smaller null variant that is used when no GPU is supported, and a
814830fallback non-variant wheel built for the default CUDA version.
815831
832+ ``pylock.toml `` integration inlines the variant metadata to keep the
833+ file standalone. This can avoid the additional network call that would
834+ be required to fetch the file, and avoids having to pin to a specific
835+ hash that could cause problems if the file changed on the index, either
836+ due to the variant metadata being updated or being generated in a way
837+ that does not guarantee stable bytewise output.
838+
816839
817840Backwards Compatibility
818841=======================
@@ -973,6 +996,8 @@ Change History
973996 rather than all compatible values, and add a fallback to ordering
974997 on variant label.
975998 - Removed the variant label length limitation.
999+ - Changed ``pylock.toml `` integration to inline variant metadata
1000+ rather than storing a URL and a hash.
9761001
9771002
9781003Appendices
0 commit comments