Skip to content

Commit ae48f92

Browse files
authored
Merge pull request #785 from pfmoore/pep643
WIP: Add sdist format specification and metadata field (PEP 643)
2 parents 8c1f843 + 75c4acc commit ae48f92

5 files changed

Lines changed: 100 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 (:term:`wheel <Wheel>`) is defined in :pep:`427`.

source/specifications/core-metadata.rst

Lines changed: 33 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
.. _core-metadata-name:
@@ -86,6 +83,36 @@ Example::
8683
Version: 1.0a2
8784

8885

86+
Dynamic (multiple use)
87+
======================
88+
89+
.. versionadded:: 2.2
90+
91+
A string containing the name of another core metadata field. The field
92+
names ``Name`` and ``Version`` may not be specified in this field.
93+
94+
When found in the metadata of a source distribution, the following
95+
rules apply:
96+
97+
1. If a field is *not* marked as ``Dynamic``, then the value of the field
98+
in any wheel built from the sdist MUST match the value in the sdist.
99+
If the field is not in the sdist, and not marked as ``Dynamic``, then
100+
it MUST NOT be present in the wheel.
101+
2. If a field is marked as ``Dynamic``, it may contain any valid value in
102+
a wheel built from the sdist (including not being present at all).
103+
104+
If the sdist metadata version is older than version 2.2, then all fields should
105+
be treated as if they were specified with ``Dynamic`` (i.e. there are no special
106+
restrictions on the metadata of wheels built from the sdist).
107+
108+
In any context other than a source distribution, ``Dynamic`` is for information
109+
only, and indicates that the field value was calculated at wheel build time,
110+
and may not be the same as the value in the sdist or in other wheels for the
111+
project.
112+
113+
Full details of the semantics of ``Dynamic`` are described in :pep:`643`.
114+
115+
89116
Platform (multiple use)
90117
=======================
91118

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
@@ -20,12 +20,21 @@ Package Distribution Metadata
2020
dependency-specifiers
2121
declaring-build-dependencies
2222
declaring-project-metadata
23-
distribution-formats
2423
platform-compatibility-tags
2524
recording-installed-packages
2625
entry-points
2726

2827

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 :file:`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+
:command:`setup.py sdist`. This document does not attempt to standardise this
16+
format, except to note that if a legacy source distribution contains a
17+
``PKG-INFO`` file using metadata version 2.2 or later, then it MUST follow
18+
the rules applicable to source distributions defined in the metadata
19+
specification.
20+
21+
Source distributions are also known as *sdists* for short.
22+
23+
Source distribution file name
24+
=============================
25+
26+
The file name of a sdist is not currently standardised, although the *de facto*
27+
form is ``{name}-{version}.tar.gz``, where ``{name}`` is the canonicalized form
28+
of the project name (see :pep:`503` for the canonicalization rules) with ``-``
29+
characters replaced with ``_``, and ``{version}`` is the project version.
30+
31+
The name and version components of the filename MUST match the values stored
32+
in the metadata contained in the file.
33+
34+
Source distribution file format
35+
===============================
36+
37+
A ``.tar.gz`` source distribution (sdist) contains a single top-level directory
38+
called ``{name}-{version}`` (e.g. ``foo-1.0``), containing the source files of
39+
the package. The name and version MUST match the metadata stored in the file.
40+
This directory must also contain a :file:`pyproject.toml` in the format defined in
41+
:ref:`declaring-build-dependencies`, and a ``PKG-INFO`` file containing
42+
metadata in the format described in the :ref:`core-metadata` specification. The
43+
metadata MUST conform to at least version 2.2 of the metadata specification.
44+
45+
No other content of a sdist is required or defined. Build systems can store
46+
whatever information they need in the sdist to build the project.
47+
48+
The tarball should use the modern POSIX.1-2001 pax tar format, which specifies
49+
UTF-8 based file names.

0 commit comments

Comments
 (0)