commit:     4b0b254144141866ac51f66ad27cadf477f43da3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 22 11:10:48 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Sep 22 11:12:49 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4b0b2541

install-qa-check.d: Fix DUS check for DISTUTILS_OPTIONAL

Fix DISTUTILS_USE_SETUPTOOLS check to process all Python implementations
with egg-infos present in site-packages (possibly none).  This fixes
eclass errors when trying to call distutils-r1 functions when it is
actually disabled in DISTUTILS_OPTIONAL ebuilds.  It also reduces noise
while processing.

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

 .../install-qa-check.d/60distutils-use-setuptools  | 63 +++++++++++-----------
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/metadata/install-qa-check.d/60distutils-use-setuptools 
b/metadata/install-qa-check.d/60distutils-use-setuptools
index 0a1688a83c5..698d832800f 100644
--- a/metadata/install-qa-check.d/60distutils-use-setuptools
+++ b/metadata/install-qa-check.d/60distutils-use-setuptools
@@ -4,31 +4,6 @@
 # QA check: verify correctness of DISTUTILS_USE_SETUPTOOLS
 # Maintainer: Python project <[email protected]>
 
-get_expected_distutils_use_setuptools() {
-       local sitedir=${D}$(python_get_sitedir)
-       local egg new_expected
-       while read -d $'\0' -r egg; do
-               if [[ -f ${egg} ]]; then
-                       # if .egg-info is a file, it's plain distutils
-                       new_expected=no
-               elif grep -q -s -F '[console_scripts]' "${egg}"/entry_points.txt
-               then
-                       # entry_points == we need rdepend
-                       new_expected=rdepend
-               elif grep -q -E -s '^setuptools' "${egg}"/requires.txt
-               then
-                       # explicit rdepend in package metadata
-                       new_expected=rdepend
-               else
-                       new_expected=bdepend
-               fi
-
-               if ! has "${new_expected}" "${expected[@]}"; then
-                       expected+=( "${new_expected[@]}" )
-               fi
-       done < <(find "${sitedir}" -name '*.egg-info' -print0)
-}
-
 distutils_use_setuptools_check() {
        # applicable only to ebuilds inheriting distutils-r1
        [[ ${_DISTUTILS_R1} ]] || return
@@ -38,18 +13,46 @@ distutils_use_setuptools_check() {
        [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]] && return
 
        local expected=()
-       _distutils-r1_run_foreach_impl get_expected_distutils_use_setuptools
+       for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
+               local EPYTHON PYTHON
+               _python_export "${impl}" EPYTHON PYTHON
+               [[ -x ${PYTHON} ]] || continue
+               local sitedir=${D}$(python_get_sitedir)
+               if [[ -d ${sitedir} ]]; then
+                       local egg new_expected
+                       while read -d $'\0' -r egg; do
+                               if [[ -f ${egg} ]]; then
+                                       # if .egg-info is a file, it's plain 
distutils
+                                       new_expected=no
+                               elif grep -q -s -F '[console_scripts]' \
+                                               "${egg}"/entry_points.txt
+                               then
+                                       # entry_points == we need rdepend
+                                       new_expected=rdepend
+                               elif grep -q -E -s '^setuptools' \
+                                               "${egg}"/requires.txt
+                               then
+                                       # explicit rdepend in package metadata
+                                       new_expected=rdepend
+                               else
+                                       new_expected=bdepend
+                               fi
+
+                               if ! has "${new_expected}" "${expected[@]}"; 
then
+                                       expected+=( "${new_expected[@]}" )
+                               fi
+                       done < <(find "${sitedir}" -name '*.egg-info' -print0)
+               fi
+       done
 
        # at this point, expected can contain: no bdepend rdepend
-       if [[ ${#expected[@]} -eq 0 ]]; then
-               eerror "No .egg-info found.  Please report a bug and CC python@"
-       elif [[ ${#expected[@]} -gt 1 ]] && has no "${expected[@]}"; then
+       if [[ ${#expected[@]} -gt 1 ]] && has no "${expected[@]}"; then
                # 'no' and '[rb]depend' are mutually exclusive
                eerror "The package seems to have used distutils and setuptools 
simultaneously."
                eerror "This could mean the package has bad conditions:"
                eerror 
"https://dev.gentoo.org/~mgorny/python-guide/distutils.html#conditional-distutils-setuptools-use-in-packages";
                eerror "Please report a bug about this and CC python@"
-       else
+       elif [[ ${#expected[@]} -gt 0 ]]; then
                # bdepend+rdepend=rdepend
                has rdepend "${expected[@]}" && expected=( rdepend )
                # at this point, expected should have exactly one value

Reply via email to