[Distutils] Finishing up PEP 517

Nick Coghlan ncoghlan at gmail.com
Sat Jun 17 10:41:35 EDT 2017

On 17 June 2017 at 17:07, Nathaniel Smith <njs at pobox.com> wrote:
> On Fri, Jun 16, 2017 at 11:28 PM, Donald Stufft <donald at stufft.io> wrote:
>>> On Jun 16, 2017, at 11:08 PM, Nathaniel Smith <njs at pobox.com> wrote:
>>> (because the legacy setup.py
>>> command errors out, because the build_sdist hook is missing, because
>>> the build_sdist hook errors out...); probably falling back on
>>> shutil.copytree.
>> Ah okay. This is where the disconnect was. I assumed if a project was using a PEP 517 build tool the result of a build_sdist failure (or a build_wheel failure) would be surfacing an error to the end user, not some sort of fallback.
> What we might be able to get away with in the PEP 517 transition is to
> provide an explicit way of signalling "build_sdist failed because
> that's just not a supported operation", so that pip could distinguish
> that from "something unexpected blew up" and only fall back in the
> first case.

That's what `prepare_wheel_input_files` gives us: if the backend
doesn't implement it, then `build_sdist` is expected to always
succeed, and any errors should be reported to the end user.

OTOH, if `build_sdist` can fail (e.g. due to missing dependencies that
aren't needed just to build a wheel), then the backend should offer a
`prepare_wheel_input_files` that offers the expected guarantee (i.e.
it will only fail for reasons that should be reported to the user
attempting to do the build).

The frontend then *won't* have a fallback copy strategy for PEP 517
backends - if `prepare_wheel_input_files` is present and fails, or if
it's missing and `build_sdist` fails, then you have a failed wheel
build on your hands.

The legacy copying strategy would then only be used when falling all
the way back to the `setup.py` interface, not as an attempt to
continue the build in the face of a backend bug.

This all gets murkier if you try to make the build_sdist hook more
complex instead of just having two different hooks for frontends to
call that tell the backend what the frontend actually wants (i.e.
either an actual sdist, or just a clean set of exported files to use
as input to a wheel build).


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

More information about the Distutils-SIG mailing list