From a1bef1e7863118a05b68935029e7e41da86fc9f8 Mon Sep 17 00:00:00 2001 From: konstin Date: Sun, 25 Aug 2024 13:00:50 +0200 Subject: [PATCH 1/2] Clarity the meaning of "match" between sdist and wheel In the current version of the description of `Dynamic` in the core metadata, it is unclear whether "match" means string equivalence or semantic equivalence. Given that pypa/packaging is reordering version specifiers between sdist and wheel when used by a build backend (which to my best knowledge are all build backend written in python), we can clarify this to semantic equivalence. --- source/specifications/core-metadata.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/specifications/core-metadata.rst b/source/specifications/core-metadata.rst index 3d06e9ab6c..d979a82fd7 100644 --- a/source/specifications/core-metadata.rst +++ b/source/specifications/core-metadata.rst @@ -122,7 +122,11 @@ When found in the metadata of a source distribution, the following rules apply: 1. If a field is *not* marked as ``Dynamic``, then the value of the field - in any wheel built from the sdist MUST match the value in the sdist. + in any wheel built from the sdist MUST be semantically equivalent to the + value in the sdist. For example, ``Foo`` and ``foo`` as distribution name + as well as ``>=2,<3`` and ``<3,>=2`` as version specifiers are semantically + equivalent. + If the field is not in the sdist, and not marked as ``Dynamic``, then it MUST NOT be present in the wheel. 2. If a single-use field is marked as ``Dynamic``, it may contain any valid From a67a0e683b7d84518e8a75836627b018e75242e2 Mon Sep 17 00:00:00 2001 From: konstin Date: Sun, 29 Nov 2026 23:14:12 +0100 Subject: [PATCH 2/2] Cover `pyproject.toml` -> `PKG-INFO` -> `METADATA` explicitly --- .../binary-distribution-format.rst | 2 ++ source/specifications/pyproject-toml.rst | 32 +++++++++++-------- .../source-distribution-format.rst | 2 ++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/source/specifications/binary-distribution-format.rst b/source/specifications/binary-distribution-format.rst index b2814f50c7..f4bf30fa93 100644 --- a/source/specifications/binary-distribution-format.rst +++ b/source/specifications/binary-distribution-format.rst @@ -228,6 +228,8 @@ The layout offers a superset of the functionality provided by the existing wininst and egg binary formats. +.. _the-dist-info-directory: + The .dist-info directory ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/source/specifications/pyproject-toml.rst b/source/specifications/pyproject-toml.rst index ac4f10edce..40aa2c4115 100644 --- a/source/specifications/pyproject-toml.rst +++ b/source/specifications/pyproject-toml.rst @@ -107,19 +107,25 @@ Declaring project metadata: the ``[project]`` table The ``[project]`` table specifies the project's :ref:`core metadata `. -There are two kinds of metadata: *static* and *dynamic*. Static -metadata is specified in the ``pyproject.toml`` file directly and -cannot be specified or changed by a tool (this includes data -*referred* to by the metadata, e.g. the contents of files referenced -by the metadata). Dynamic metadata is listed via the ``dynamic`` key -(defined later in this specification) and represents metadata that a -tool will later provide. - -A key whose value is a list or a table of arbitrary entries MAY be -specified statically *and* listed in ``dynamic`` at the same time. In -that case the entries given statically are fixed and a build back-end -MAY only *append* further entries to them; the back-end MUST NOT -remove, reorder, or modify any statically-specified entries. See the +There are two kinds of metadata: *static* and *dynamic*. + +Static metadata is specified in the ``pyproject.toml`` file directly and MUST +NOT be changed by tools. Source distributions and wheels built for this project +MUST have semantically equivalent values in +:ref:`PKG-INFO ` (source distribution +metadata) and :ref:`METADATA ` (wheel metadata). For +example, ``Foo`` and ``foo`` as distribution name as well as ``>=2,<3`` and +``<3,>=2`` as version specifiers are semantically equivalent. This mandate +includes data *referred* to by the metadata, e.g. the contents of files +referenced by the metadata MUST NOT be changed. + +Dynamic metadata is listed via the ``dynamic`` key (defined later in this +specification) and represents metadata that a tool will later provide. A key +whose value is a list or a table of arbitrary entries MAY be specified +statically *and* listed in ``dynamic`` at the same time. In that case the +entries given statically are fixed and a build back-end MAY only *append* +further entries to them; the back-end MUST NOT remove, reorder, or modify any +statically-specified entries. See the :ref:`dynamic ` key for details. The lack of a ``[project]`` table implicitly means the :term:`build backend ` diff --git a/source/specifications/source-distribution-format.rst b/source/specifications/source-distribution-format.rst index 569173f9d1..71103f340a 100644 --- a/source/specifications/source-distribution-format.rst +++ b/source/specifications/source-distribution-format.rst @@ -55,6 +55,8 @@ by the ``.tar.gz`` suffix and the presence of precisely *one* hyphen in the file Code that does this may then use the distribution name and version from the filename without further verification. +.. _source-distribution-file-format: + Source distribution file format ===============================