commit:     e321a72564094603b5cb8c43dd7a54f970e1aa79
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 31 08:39:49 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Feb  1 18:33:20 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e321a725

distutils-r1.eclass: Add DISTUTILS_DEPS output var for PEP 517 mode

The PEP 517 build-time deps have gotten more complex, and largely depend
on the internal eclass logic used to build and install wheels.
Introduce a DISTUTILS_DEPS output variable that contains the correct
BDEPEND string for use in DISTUTILS_OPTIONAL=1 ebuilds.

Bug: https://bugs.gentoo.org/832337
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/distutils-r1.eclass | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 4a9fdb4018b4..a0ad598eb58f 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -128,6 +128,24 @@ esac
 # It is available only in non-PEP517 mode.  It needs to be set before
 # the inherit line.
 
+# @ECLASS-VARIABLE: DISTUTILS_DEPS
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated build-time dependency string for the build
+# system packages.  This string is automatically appended to BDEPEND
+# unless DISTUTILS_OPTIONAL is used.  This variable is available only
+# in PEP 517 mode.
+#
+# Example use:
+# @CODE
+# DISTUTILS_OPTIONAL=1
+# # ...
+# RDEPEND="${PYTHON_DEPS}"
+# BDEPEND="
+#     ${PYTHON_DEPS}
+#     ${DISTUTILS_DEPS}"
+# @CODE
+
 if [[ ! ${_DISTUTILS_R1} ]]; then
 
 [[ ${EAPI} == 6 ]] && inherit eutils xdg-utils
@@ -156,7 +174,7 @@ _distutils_set_globals() {
 
                # installer is used to install the wheel
                # tomli is used to read build-backend from pyproject.toml
-               bdep+='
+               bdep='
                        >=dev-python/installer-0.4.0_p20220124[${PYTHON_USEDEP}]
                        dev-python/tomli[${PYTHON_USEDEP}]'
                case ${DISTUTILS_USE_PEP517} in
@@ -213,6 +231,20 @@ _distutils_set_globals() {
                [[ -n ${rdep} ]] && rdep="$(python_gen_cond_dep "${rdep}")"
        fi
 
+       if [[ ${DISTUTILS_USE_PEP517} ]]; then
+               if [[ ${DISTUTILS_DEPS+1} ]]; then
+                       if [[ ${DISTUTILS_DEPS} != "${bdep}" ]]; then
+                               eerror "DISTUTILS_DEPS have changed between 
inherits!"
+                               eerror "Before: ${DISTUTILS_DEPS}"
+                               eerror "Now   : ${bdep}"
+                               die "DISTUTILS_DEPS integrity check failed"
+                       fi
+               else
+                       DISTUTILS_DEPS=${bdep}
+                       readonly DISTUTILS_DEPS
+               fi
+       fi
+
        if [[ ! ${DISTUTILS_OPTIONAL} ]]; then
                RDEPEND="${PYTHON_DEPS} ${rdep}"
                if [[ ${EAPI} != 6 ]]; then

Reply via email to