commit:     ba7451e29bdb6b35971f8639981a2c905bd9bf6b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  7 15:39:10 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun  8 07:53:49 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ba7451e2

distutils-r1.eclass: Future-proof python_install() for empty root

Account for the possibility that ${BUILD_DIR}/install does not contain
any files to merge, in preparation for DISTUTILS_USE_PEP517=no.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

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

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index e5e11c75e39f..370b8bb7c6e0 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1484,6 +1484,7 @@ distutils-r1_python_install() {
        _python_check_EPYTHON
 
        local scriptdir=${EPREFIX}/usr/bin
+       local merge_root=
        if [[ ${DISTUTILS_USE_PEP517} ]]; then
                local root=${BUILD_DIR}/install
                # remove the altered bindir, executables from the package
@@ -1495,6 +1496,10 @@ distutils-r1_python_install() {
                                mv "${wrapped_scriptdir}" "${root}${scriptdir}" 
|| die
                        fi
                fi
+               # prune empty directories to see if ${root} contains anything
+               # to merge
+               find "${BUILD_DIR}"/install -type d -empty -delete || die
+               [[ -d ${BUILD_DIR}/install ]] && merge_root=1
        else
                local root=${D%/}/_${EPYTHON}
                [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D%/}
@@ -1521,6 +1526,8 @@ distutils-r1_python_install() {
                addpredict /usr/local # bug 498232
 
                if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
+                       merge_root=1
+
                        # user may override --install-scripts
                        # note: this is poor but distutils argv parsing is dumb
 
@@ -1549,7 +1556,7 @@ distutils-r1_python_install() {
                esetup.py "${args[@]}"
        fi
 
-       if [[ ! ${DISTUTILS_SINGLE_IMPL} || ${DISTUTILS_USE_PEP517} ]]; then
+       if [[ ${merge_root} ]]; then
                multibuild_merge_root "${root}" "${D%/}"
                if [[ ${DISTUTILS_USE_PEP517} ]]; then
                        # we need to recompile everything here in order to embed

Reply via email to