[Distutils] Provisionally accepting PEP 517's declarative build system interface
Donald Stufft
donald at stufft.io
Fri Jun 2 13:14:30 EDT 2017
> On Jun 2, 2017, at 12:39 PM, Paul Moore <p.f.moore at gmail.com> wrote:
>
>>
>> * The copy_the_files hook is optional, if it exists it SHOULD produce a tree
>> that when the build_wheel hook is called in it, will produce a wheel that is
>> equivalent to one that would have been built had the build_sdist hook been
>> called instead.
>
> This is precisely the "should look like we built a sdist" principle,
> so I'm a solid +1 on this, too. It might be worth stating that
> copy_the_files is only intended to be called after a failed call to
> build_sdist. I don't know if backends would care, but I don't think we
> should worry about having to support use of copy_the_files as anything
> other than a build_sdist fallback.
>
>> * If the copy_the_files hook is not defined, then the build frontend is free
>> to just directory call the build_sdist command instead.
>
> Sorry? I assume here that you mean "directly call the build_wheel hook
> in the original source tree"? That's OK, but I think we should be
> clear that if this happens, it is the backend's responsibility to
> ensure that the build is equivalent to building from a sdist. It might
> even be appropriate for the front end to warn if this happens -
> "Unable to build out of tree - results may differ from a clean build"
> (The intent is to remind people that they aren't testing the actual
> sdist they will be deploying, the issue that Nick pointed out).
Should have kept reading before sending my email, sorry!
The steps here would basically be (for building from something that isn’t already a .tar.gz or a .whl):
# Get our backend using the PEP 517 resolving methods
backend = get_the_backend()
# Get a copied source tree that is acceptable for using to build a wheel. We
# allow copy_files to be used in place of build_sdist to provide an optimization
# in cases where build_sdist would be very slow. However the build backend
# must ensure that the resulting wheel would not be different than if we had
# built it from the sdist instead.
If hasattr(backend, “copy_files”):
try:
backend.copy_files(…)
except Exception:
backend.build_sdist(…)
else:
backend.build_sdist(…)
# Determine what depends we need to install the wheel file, we allow the
# build tool to optionally give us the deps without actually invoking the wheel build
# as an optimization that building the wheel might take awhile, however
# the build backend must ensure that the metadata returned here matches the final
# wheel built.
If hasattr(backend, “get_wheel_metadata”):
backend.get_wheel_metadata(…)
has_already_built_wheel = False
else:
backend.build_wheel(…)
has_already_built_wheel = True
# Resolve dependencies, etc
# Go on to build the wheel if we haven’t already built it.
If not has_already_built_wheel:
backend.build_wheel(…)
# Install the wheel
—
Donald Stufft
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20170602/ac952bc8/attachment.html>
More information about the Distutils-SIG
mailing list