|
| 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