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 thatcopy_the_files is only intended to be called after a failed call tobuild_sdist. I don't know if backends would care, but I don't think weshould worry about having to support use of copy_the_files as anythingother than a build_sdist fallback.
* 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
* If the copy_the_files hook is not defined, then the build frontend is freeSorry? I assume here that you mean "directly call the build_wheel hookin the original source tree"? That's OK, but I think we should beclear that if this happens, it is the backend's responsibility toensure that the build is equivalent to building from a sdist. It mighteven 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 actualsdist they will be deploying, the issue that Nick pointed out).
to just directory call the build_sdist command instead.
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”):
# 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”):
has_already_built_wheel = False
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:
# Install the wheel