[Distutils] PEP 517: Build frontend responsibilities

Nick Coghlan ncoghlan at gmail.com
Thu Aug 17 22:51:25 EDT 2017


On 18 August 2017 at 02:05, 12345 67890 <xoviat at gmail.com> wrote:
> After reviewing the PEP, I personally feel that it relies too much on the
> backend Doing The Right Thing. As it currently stands, it is my
> understanding that the build backend is called in the source directory and
> is then responsible for handling the entire process to build a compliant
> wheel. In a PEP 517 world, the build backends may be poorly written
> initially and may not fully comply with the PEP’s goal to produce the same
> wheel that would be produced from an sdist.
>
> Current process:
>
> Frontend calls backend in source directory build-wheel

The PEP *allows* this, but it doesn't *require* it.

> Proposed process:
>
> Frontend copies source tree to temporary directory
> Frontend invokes build-sdist to build an sdist
> Frontend extracts sdist to new temporary directory
> Frontend reloads backend from sdist directory and invokes build-wheel

A particularly paranoid front-end remains free to work this way if it wants to.

>From the PEP's point of view, it's just four distinct operations:

Step 0: make a copy of the original source tree
Step 1: build an sdist from the copied source tree
Step 2: unpack the sdist
Step 3: build a wheel from the unpacked sdist

> The proposed process is more computationally intensive, but moves compliance
> logic out of the build backend. In addition, we can make some modifications
> based on this proposed process:
>
> * Remove parameter for build_dir in build_wheel since it is always the current
> directory

We've had that discussion - build_dir models something different from
what you propose (specifically, it's designed to invoke the backend's
native out-of-tree build support, when that's what the frontend
actually wants to invoke. If a frontend doesn't want that, don't use
the setting)

> Optimization: add new parameter to build_sdist called copy_extra, that when
> set to false, only includes files in sdist needed to build a  wheel.

No, this is the operation we decided makes no sense (and hence removed
from the latest iteration of the PEP), because no build system we
could find actually provides it natively.

That means it would necessarily be a Python-specific capability
anyway, and that further means that any backend which could be trusted
to implement this feature correctly can instead be trusted to
implement building an sdist or wheel directly from a source tree
correctly.

It's also not a major concern if early backend iterations *don't* do
things correctly - those errors will be reported as bugs, fixed
versions of the backends will be released, and future builds will
start doing the right thing.

> Specify that build_wheel should fail if PKG-INFO is not present so that it
> is always invoked in an sdist

No, we don't want to make that a mandatory requirement, since
frontends are already free to enforce that rule if they want to (by
checking for PKG-INFO before they call build_wheel), and particular
backends are also free to enforce it for the packages they manage (by
raising NotImplemented when they don't find PKG-INFO).

Cheers,
Nick.

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


More information about the Distutils-SIG mailing list