Skip to content

Commit 94dbee0

Browse files
takluyverncoghlan
authored andcommitted
Update PEP 517 to use pyproject.toml from PEP 518 (#51)
Update PEP 517 to use pyproject.toml from PEP 518
1 parent 3b87611 commit 94dbee0

File tree

1 file changed

+53
-66
lines changed

1 file changed

+53
-66
lines changed

pep-0517.txt

Lines changed: 53 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ PEP: 517
22
Title: A build-system independent format for source trees
33
Version: $Revision$
44
Last-Modified: $Date$
5-
Author: Nathaniel J. Smith <njs@pobox.com>
5+
Author: Nathaniel J. Smith <njs@pobox.com>,
6+
Thomas Kluyver <thomas@kluyver.me.uk>
67
BDFL-Delegate: Nick Coghlan <ncoghlan@gmail.com>
78
Discussions-To: <distutils-sig@python.org>
89
Status: Draft
@@ -99,63 +100,55 @@ specification is encoded in the source code and documentation of
99100
``distutils``, ``setuptools``, ``pip``, and other tools. We'll refer
100101
to it as the ``setup.py``\-style.
101102

102-
Here we define a new ``pypackage.json``\-style source tree. This
103-
consists of any directory which contains a file named
104-
``pypackage.json``. (If a tree contains both ``pypackage.json`` and
105-
``setup.py`` then it is a ``pypackage.json``\-style source tree, and
106-
``pypackage.json``\-aware tools should ignore the ``setup.py``; this
107-
allows packages to include a ``setup.py`` for compatibility with old
108-
build frontends, while using the new system with new build frontends.)
103+
Here we define a new style of source tree based around the
104+
``pyproject.toml`` file defined in PEP 518, extending the
105+
``[build-system]`` table in that file with one additional key,
106+
``build_backend``. Here's an example of how it would look::
109107

110-
This file has the following schema. Extra keys are ignored.
108+
[build-system]
109+
# Defined by PEP 518:
110+
requires = ["flit"]
111+
# Defined by this PEP:
112+
build_backend = "flit.api:main"
111113

112-
schema
113-
The version of the schema. This PEP defines version "1". Defaults to "1"
114-
when absent. All tools reading the file MUST error on an unrecognised
115-
schema version.
114+
``build_backend`` is a string naming a Python object that will be
115+
used to perform the build (see below for details). This is formatted
116+
following the same ``module:object`` syntax as a ``setuptools`` entry
117+
point. For instance, if the string is ``"flit.api:main"`` as in the
118+
example above, this object would be looked up by executing the
119+
equivalent of::
116120

117-
bootstrap_requires
118-
Optional list of PEP 508 dependency specifications that the
119-
build frontend must ensure are available before invoking the build
120-
backend. For instance, if using flit, then the requirements might
121-
be::
121+
import flit.api
122+
backend = flit.api.main
122123

123-
"bootstrap_requires": ["flit"]
124+
It's also legal to leave out the ``:object`` part, e.g. ::
124125

125-
build_backend
126-
A mandatory string naming a Python object that will be used to
127-
perform the build (see below for details). This is formatted
128-
following the same ``module:object`` syntax as a ``setuptools``
129-
entry point. For instance, if using flit, then the build system
130-
might be specified as::
126+
build_backend = "flit.api"
131127

132-
"build_system": "flit.api:main"
128+
which acts like::
133129

134-
and this object would be looked up by executing the equivalent of::
130+
import flit.api
131+
backend = flit.api
135132

136-
import flit.api
137-
backend = flit.api.main
133+
Formally, the string should satisfy this grammar::
138134

139-
It's also legal to leave out the ``:object`` part, e.g. ::
135+
identifier = (letter | '_') (letter | '_' | digit)*
136+
module_path = identifier ('.' identifier)*
137+
object_path = identifier ('.' identifier)*
138+
entry_point = module_path (':' object_path)?
140139

141-
"build_system": "flit.api"
140+
And we import ``module_path`` and then lookup
141+
``module_path.object_path`` (or just ``module_path`` if
142+
``object_path`` is missing).
142143

143-
which acts like::
144-
145-
import flit.api
146-
backend = flit.api
147-
148-
Formally, the string should satisfy this grammar::
149-
150-
identifier = (letter | '_') (letter | '_' | digit)*
151-
module_path = identifier ('.' identifier)*
152-
object_path = identifier ('.' identifier)*
153-
entry_point = module_path (':' object_path)?
154-
155-
And we import ``module_path`` and then lookup
156-
``module_path.object_path`` (or just ``module_path`` if
157-
``object_path`` is missing).
144+
If the ``pyproject.toml`` file is absent, or the ``build_backend``
145+
key is missing, the source tree is not using this specification, and
146+
tools should fall back to running ``setup.py``.
158147

148+
Where the ``build_backend`` key exists, it takes precedence over
149+
``setup.py``, and source trees need not include ``setup.py`` at all.
150+
Projects may still wish to include a ``setup.py`` for compatibility
151+
with tools that do not use this spec.
159152

160153
=========================
161154
Build backend interface
@@ -170,7 +163,7 @@ argument is described after the individual hooks::
170163

171164
This hook MUST return an additional list of strings containing PEP 508
172165
dependency specifications, above and beyond those specified in the
173-
``pypackage.json`` file. Example::
166+
``pyproject.toml`` file. Example::
174167

175168
def get_build_requires(config_settings):
176169
return ["wheel >= 0.25", "setuptools"]
@@ -304,11 +297,11 @@ following criteria:
304297

305298
- The ``get_build_requires`` hook is executed in an environment
306299
which contains the bootstrap requirements specified in the
307-
``pypackage.json`` file.
300+
``pyproject.toml`` file.
308301

309302
- All other hooks are executed in an environment which contains both
310-
the bootstrap requirements specified in the ``pypackage.json`` hook
311-
and those specified by the ``get_build_requires`` hook.
303+
the bootstrap requirements specified in the ``pyproject.toml``
304+
hook and those specified by the ``get_build_requires`` hook.
312305

313306
- This must remain true even for new Python subprocesses spawned by
314307
the build environment, e.g. code like::
@@ -370,8 +363,8 @@ explicitly requested build-dependencies. This has two benefits:
370363
However, there will also be situations where build-requirements are
371364
problematic in various ways. For example, a package author might
372365
accidentally leave off some crucial requirement despite our best
373-
efforts; or, a package might declare a build-requirement on `foo >=
374-
1.0` which worked great when 1.0 was the latest version, but now 1.1
366+
efforts; or, a package might declare a build-requirement on ``foo >=
367+
1.0`` which worked great when 1.0 was the latest version, but now 1.1
375368
is out and it has a showstopper bug; or, the user might decide to
376369
build a package against numpy==1.7 -- overriding the package's
377370
preferred numpy==1.8 -- to guarantee that the resulting build will be
@@ -399,7 +392,7 @@ undefined, but basically comes down to: a file named
399392
``{NAME}-{VERSION}.{EXT}``, which unpacks into a buildable source tree
400393
called ``{NAME}-{VERSION}/``. Traditionally these have always
401394
contained ``setup.py``\-style source trees; we now allow them to also
402-
contain ``pypackage.json``\-style source trees.
395+
contain ``pyproject.toml``\-style source trees.
403396

404397
Integration frontends require that an sdist named
405398
``{NAME}-{VERSION}.{EXT}`` will generate a wheel named
@@ -410,9 +403,8 @@ Integration frontends require that an sdist named
410403
Comparison to competing proposals
411404
===================================
412405

413-
The primary difference between this and competing proposals (`in
414-
particular
415-
<https://github.com/pypa/interoperability-peps/pull/54/files>`_) is
406+
The primary difference between this and competing proposals (in
407+
particular, PEP 516) is
416408
that our build backend is defined via a Python hook-based interface
417409
rather than a command-line based interface.
418410

@@ -580,7 +572,7 @@ Furthermore, our mechanism should also fulfill two more goals: (a) If
580572
new versions of e.g. ``pip`` and ``flit`` are both updated to support
581573
the new interface, then this should be sufficient for it to be used;
582574
in particular, it should *not* be necessary for every project that
583-
*uses* ``flit`` to update its individual ``pypackage.json`` file. (b)
575+
*uses* ``flit`` to update its individual ``pyproject.toml`` file. (b)
584576
We do not want to have to spawn extra processes just to perform this
585577
negotiation, because process spawns can easily become a bottleneck when
586578
deploying large multi-package stacks on some platforms (Windows).
@@ -601,11 +593,10 @@ process, it can easily write it to do something like::
601593
In the alternative where the public interface boundary is placed at
602594
the subprocess call, this is not possible -- either we need to spawn
603595
an extra process just to query what interfaces are supported (as was
604-
included in an earlier version of `this alternative PEP
605-
<https://github.com/pypa/interoperability-peps/pull/54/files>`_), or
596+
included in an earlier draft of PEP 516, an alternative to this), or
606597
else we give up on autonegotiation entirely (as in the current version
607598
of that PEP), meaning that any changes in the interface will require
608-
N individual packages to update their ``pypackage.json`` files before
599+
N individual packages to update their ``pyproject.toml`` files before
609600
any change can go live, and that any changes will necessarily be
610601
restricted to new releases.
611602

@@ -658,10 +649,6 @@ above, there are a few other differences in this proposal:
658649
step and the wheel building step. I guess everyone probably will
659650
agree this is a good idea?
660651

661-
* We call our config file ``pypackage.json`` instead of
662-
``pypa.json``. This is because it describes a package, rather than
663-
describing a packaging authority. But really, who cares.
664-
665652
* We provide more detailed recommendations about the build environment,
666653
but these aren't normative anyway.
667654

@@ -673,7 +660,7 @@ above, there are a few other differences in this proposal:
673660
A goal here is to make it as simple as possible to convert old-style
674661
sdists to new-style sdists. (E.g., this is one motivation for
675662
supporting dynamic build requirements.) The ideal would be that there
676-
would be a single static pypackage.json that could be dropped into any
663+
would be a single static ``pyproject.toml`` that could be dropped into any
677664
"version 0" VCS checkout to convert it to the new shiny. This is
678665
probably not 100% possible, but we can get close, and it's important
679666
to keep track of how close we are... hence this section.
@@ -700,7 +687,7 @@ automatically upgrade packages to the new format:
700687
check whether they do this, and if so then when upgrading to the
701688
new system they will have to start explicitly declaring these
702689
dependencies (either via ``setup_requires=`` or via static
703-
declaration in ``pypackage.json``).
690+
declaration in ``pyproject.toml``).
704691

705692
2) There currently exist packages which do not declare consistent
706693
metadata (e.g. ``egg_info`` and ``bdist_wheel`` might get different

0 commit comments

Comments
 (0)