Signed-off-by: Michał Górny <mgo...@gentoo.org> --- eclass/distutils-r1.eclass | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index d32e5929177e..7dfc8c7a3c30 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -134,13 +134,20 @@ # # - sip - sipbuild backend # -# - standalone - standalone build systems without external deps -# (used for bootstrapping). +# - standalone - standalone/local build systems # # - uv-build - uv-build backend (using dev-python/uv) # -# The variable needs to be set before the inherit line. The eclass -# adds appropriate build-time dependencies and verifies the value. +# The variable needs to be set before the inherit line. If another +# value than "standalone" and "no" is used, The eclass adds appropriate +# build-time dependencies, verifies the value and calls the appropriate +# modern entry point for the backend. With DISTUTILS_UPSTREAM_PEP517, +# this variable can be used to override the upstream build backend. +# +# The value of "standalone" indicates that upstream is using a custom, +# local build backend. In this mode, the eclass does not add any +# dependencies, disables build backend verification and uses the exact +# entry point listed in pyproject.toml. # # The special value "no" indicates that the package has no build system. # This is not equivalent to unset DISTUTILS_USE_PEP517 (legacy mode). @@ -162,6 +169,12 @@ # overriden to workaround the eclass check, when it is desirable # to build the wheel using other backend than the one used upstream. # +# When using it, ideally it should list the build backend actually used +# upstream, so the eclass will throw an error if that backend changes +# (and therefore overrides may need to change as well). As a special +# case, setting it to "standalone" disables the check entirely (while +# still forcing the backend, unlike DISTUTILS_USE_PEP517=standalone). +# # Please note that even in packages using PEP621 metadata, there can # be subtle differences between the behavior of different PEP517 build # backends, for example regarding finding package files. When using @@ -1150,11 +1163,23 @@ _distutils-r1_get_backend() { fi fi + # if DISTUTILS_USE_PEP517 is "standalone", we respect the exact + # backend used in pyproject.toml; otherwise we force the backend + # based on DISTUTILS_USE_PEP517 if [[ ${DISTUTILS_USE_PEP517} == standalone ]]; then echo "${build_backend}" return fi + # we can output it early, even if we die below + echo "$(_distutils-r1_key_to_backend "${DISTUTILS_USE_PEP517}")" + + # skip backend verification if DISTUTILS_UPSTREAM_PEP517 + # is "standalone" + if [[ ${DISTUTILS_UPSTREAM_PEP517} == standalone ]]; then + return + fi + # verify that the ebuild correctly specifies the build backend local expected_backend=$( _distutils-r1_key_to_backend \ @@ -1189,8 +1214,6 @@ _distutils-r1_get_backend() { > "${T}"/.distutils_deprecated_backend_warned || die fi fi - - echo "$(_distutils-r1_key_to_backend "${DISTUTILS_USE_PEP517}")" } # @FUNCTION: distutils_wheel_install