[Distutils] A possible refactor/streamlining of PEP 517

Nick Coghlan ncoghlan at gmail.com
Sat Jul 15 05:03:42 EDT 2017


On 15 July 2017 at 18:45, Paul Moore <p.f.moore at gmail.com> wrote:
> On 15 July 2017 at 09:16, Nathaniel Smith <njs at pobox.com> wrote:
>> And then there's another thing called an "in place build", as opposed to an
>> "out of place" build. In this case the distinction is just that an in-place
>> build stores intermediate build artifacts somewhere inside the source tree,
>> so that future builds using that source tree can take advantage of them,
>> while an out-of-place build stores them in some other designated directory.
>
> ... where the backend can still manage to take advantage of them if it
> so chooses (and is able to - but so far no-one has a concrete example
> of where that's not possible).

The path I took for adding out-of-tree build support to the example
backend in PEP 517 was to have it call its own sdist building
machinery and then unpack that archive into the build directory:
https://github.com/python/peps/pull/310/files

(There are also some spec clarifications in that PR that arose from
updating the example to implement the latest version of the API).

The difference between this and the previous "prepare_build_directory"
hook is that it puts the decision on how to handle directory
preparation entirely in the hands of the backend:

- for our naive example backend, build_sdist essentially can't fail,
so there's no problem in using it for build preparation
- for a backend like flit, where build_sdist *can* fail, but
out-of-tree builds can be supported a different way, then flit can
just handle it
- for a backend like enscons, the request for an out-of-tree build can
be delegated to the underlying build system

Regardless of which of those is the case, the frontend is relying on
the backend to have implemented out of tree build support properly.

Given this arrangement, I'd actually encourage pip to start out by
only using the "sdist -> wheel -> install" path for legacy source
trees, and (at least initially) rely entirely on out-of-tree build
support in the backend for PEP 517 source trees.

Only if pip was regularly getting bug reports that turned out to be
due to misbehaving out-of-tree build support in backends would it
switch to first attempting the "sdist -> wheel -> install" path even
for PEP 517 trees.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Distutils-SIG mailing list