Skip to content

Commit d3f138b

Browse files
committed
Add sdist format specification and metadata field (PEP 643)
1 parent b5f7f5d commit d3f138b

5 files changed

Lines changed: 93 additions & 32 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
.. _binary-distribution-format:
3+
4+
==========================
5+
Binary distribution format
6+
==========================
7+
8+
The binary distribution format (``wheel``) is defined in :pep:`427`.

source/specifications/core-metadata.rst

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
Core metadata specifications
55
============================
66

7-
The current core metadata file format, version 2.1, is specified in :pep:`566`.
8-
It defines the following specification as the canonical source for the core
9-
metadata file format.
10-
117
Fields defined in the following specification should be considered valid,
128
complete and not subject to change. The required fields are:
139

@@ -32,7 +28,8 @@ Metadata-Version
3228

3329
.. versionadded:: 1.0
3430

35-
Version of the file format; legal values are "1.0", "1.1", "1.2" and "2.1".
31+
Version of the file format; legal values are "1.0", "1.1", "1.2", "2.1"
32+
and "2.2".
3633

3734
Automated tools consuming metadata SHOULD warn if ``metadata_version`` is
3835
greater than the highest version they support, and MUST fail if
@@ -46,7 +43,7 @@ all of the needed fields.
4643

4744
Example::
4845

49-
Metadata-Version: 2.1
46+
Metadata-Version: 2.2
5047

5148

5249
Name
@@ -82,6 +79,30 @@ Example::
8279
Version: 1.0a2
8380

8481

82+
Dynamic (multiple use)
83+
======================
84+
85+
.. versionadded:: 2.2
86+
87+
Only permitted in source distribution (sdist) file metadata.
88+
89+
A string containing the name of another core metadata field. Only the following
90+
metadata field names may be used as the value of the ``Dynamic`` field.
91+
92+
* ``Platform``
93+
* ``Supported-Platform``
94+
* ``Requires-Dist``
95+
* ``Requires-External``
96+
* ``Provides-Extra``
97+
* ``Provides-Dist``
98+
* ``Obsoletes-Dist``
99+
100+
Unless specified via ``Dynamic``, *all* metadata in a wheel must be identical to
101+
the metadata of the sdist from which the wheel was built. If a field is named in
102+
``Dynamic`` in the sdist, then there is no constraint on what value that field
103+
may have in wheels built from the sdist.
104+
105+
85106
Platform (multiple use)
86107
=======================
87108

source/specifications/distribution-formats.rst

Lines changed: 0 additions & 25 deletions
This file was deleted.

source/specifications/index.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ Package Distribution Metadata
1919
version-specifiers
2020
dependency-specifiers
2121
declaring-build-dependencies
22-
distribution-formats
2322
platform-compatibility-tags
2423
recording-installed-packages
2524
entry-points
2625

2726

27+
Package Distribution File Formats
28+
---------------------------------
29+
30+
.. toctree::
31+
:maxdepth: 1
32+
33+
source-distribution-format
34+
binary-distribution-format
35+
36+
2837
Package Index Interfaces
2938
------------------------
3039

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
.. _source-distribution-format:
3+
4+
==========================
5+
Source distribution format
6+
==========================
7+
8+
The current standard format of source distribution format is identified by the
9+
presence of a ``pyproject.toml`` file in the distribution archive. The layout
10+
of such a distribution was originally specified in :pep:`517` and is formally
11+
documented here.
12+
13+
There is also the legacy source distribution format, implicitly defined by the
14+
behaviour of ``distutils`` module in the standard library, when executing
15+
``setup.py sdist``. This document does not attempt to standardise this format,
16+
except to note that if a legacy sdist contains a ``PKG-INFO`` file holding
17+
metadata version 2.2 or later, that sdist MUST follow the rules for sdists
18+
defined by the metadata specification.
19+
20+
Source distributions are also known as *sdists* for short.
21+
22+
Source distribution file name
23+
=============================
24+
25+
The file name of a sdist is not currently standardised, although the *de facto*
26+
form is ``{name}-{version}.tar.gz``, where ``{name}`` is the canonicalized form
27+
of the project name (see :pep:`503` for the canonicalization rules) and
28+
``{version}`` is the project version.
29+
30+
The name and version components of the filename MUST match the values stored
31+
in the metadata contained in the file.
32+
33+
Source distribution file format
34+
===============================
35+
36+
A .tar.gz source distribution (sdist) contains a single top-level directory
37+
called ``{name}-{version}`` (e.g. ``foo-1.0``), containing the source files of
38+
the package. The name and version MUST match the metadata stored in the file.
39+
This directory must also contain a ``pyproject.toml`` in the format defined in
40+
:ref:`declaring-build-dependencies`, and a ``PKG-INFO`` file containing
41+
metadata in the format described in the :ref:`core-metadata` specification. The
42+
metadata MUST conform to at least version 2.2 of the metadata specification.
43+
44+
No other content of a sdist is required or defined. Build systems can store
45+
whatever information they need in the sdist to build the project.
46+
47+
The tarball should use the modern POSIX.1-2001 pax tar format, which specifies
48+
UTF-8 based file names.

0 commit comments

Comments
 (0)