Skip to content

Commit 9d06acf

Browse files
authored
Merge pull request #1337 from jeanas/pep518
Import PEP 518 specification
2 parents d0fbae2 + 3d8231b commit 9d06acf

File tree

1 file changed

+96
-3
lines changed

1 file changed

+96
-3
lines changed

source/specifications/declaring-build-dependencies.rst

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,99 @@
55
Declaring build system dependencies
66
===================================
77

8-
``pyproject.toml`` is a build system independent file format defined in :pep:`518`
9-
that projects may provide in order to declare any Python level dependencies that
10-
must be installed in order to run the project's build system successfully.
8+
The ``pyproject.toml`` file is written in `TOML <https://toml.io>`_.
9+
Among other metadata (such as :ref:`project metadata <declaring-project-metadata>`),
10+
it declares any Python level dependencies that must be installed in order to
11+
run the project's build system successfully.
12+
13+
.. TODO: move this sentence elsewhere
14+
15+
Tables not defined by PyPA specifications are reserved for future use.
16+
17+
18+
build-system table
19+
------------------
20+
21+
.. TODO: merge with PEP 517
22+
23+
The ``[build-system]`` table is used to store build-related data.
24+
Initially, only one key of the table is valid and is mandatory
25+
for the table: ``requires``. This key must have a value of a list
26+
of strings representing dependencies required to execute the
27+
build system. The strings in this list follow the :ref:`version specifier
28+
specification <version-specifiers>`.
29+
30+
An example ``build-system`` table for a project built with
31+
``setuptools`` is:
32+
33+
.. code-block:: toml
34+
35+
[build-system]
36+
# Minimum requirements for the build system to execute.
37+
requires = ["setuptools"]
38+
39+
Build tools are expected to use the example configuration file above as
40+
their default semantics when a ``pyproject.toml`` file is not present.
41+
42+
Tools should not require the existence of the ``[build-system]`` table.
43+
A ``pyproject.toml`` file may be used to store configuration details
44+
other than build-related data and thus lack a ``[build-system]`` table
45+
legitimately. If the file exists but is lacking the ``[build-system]``
46+
table then the default values as specified above should be used.
47+
If the table is specified but is missing required fields then the tool
48+
should consider it an error.
49+
50+
51+
.. TODO: move elsewhere
52+
53+
tool table
54+
----------
55+
56+
The ``[tool]`` table is where any tool related to your Python
57+
project, not just build tools, can have users specify configuration
58+
data as long as they use a sub-table within ``[tool]``, e.g. the
59+
`flit <https://pypi.python.org/pypi/flit>`_ tool would store its
60+
configuration in ``[tool.flit]``.
61+
62+
A mechanism is needed to allocate names within the ``tool.*``
63+
namespace, to make sure that different projects do not attempt to use
64+
the same sub-table and collide. Our rule is that a project can use
65+
the subtable ``tool.$NAME`` if, and only if, they own the entry for
66+
``$NAME`` in the Cheeseshop/PyPI.
67+
68+
JSON Schema
69+
-----------
70+
71+
To provide a type-specific representation of the resulting data from
72+
the TOML file for illustrative purposes only, the following
73+
`JSON Schema <https://json-schema.org>`_ would match the data format:
74+
75+
.. code-block:: json
76+
77+
{
78+
"$schema": "http://json-schema.org/schema#",
79+
80+
"type": "object",
81+
"additionalProperties": false,
82+
83+
"properties": {
84+
"build-system": {
85+
"type": "object",
86+
"additionalProperties": false,
87+
88+
"properties": {
89+
"requires": {
90+
"type": "array",
91+
"items": {
92+
"type": "string"
93+
}
94+
}
95+
},
96+
"required": ["requires"]
97+
},
98+
99+
"tool": {
100+
"type": "object"
101+
}
102+
}
103+
}

0 commit comments

Comments
 (0)