commit:     697ade8b8aa51f6bba030a1c01c1f9896f3d7719
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 22 07:32:33 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Sep 22 07:33:52 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=697ade8b

install-qa-check.d: Simply DISTUTILS_USE_SETUPTOOLS logic

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

 .../install-qa-check.d/60distutils-use-setuptools  | 49 +++++++++++-----------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/metadata/install-qa-check.d/60distutils-use-setuptools 
b/metadata/install-qa-check.d/60distutils-use-setuptools
index 551cb0f0b6c..0a1688a83c5 100644
--- a/metadata/install-qa-check.d/60distutils-use-setuptools
+++ b/metadata/install-qa-check.d/60distutils-use-setuptools
@@ -5,8 +5,6 @@
 # Maintainer: Python project <[email protected]>
 
 get_expected_distutils_use_setuptools() {
-       [[ ${integrity_error_new} ]] && return 1
-
        local sitedir=${D}$(python_get_sitedir)
        local egg new_expected
        while read -d $'\0' -r egg; do
@@ -25,18 +23,8 @@ get_expected_distutils_use_setuptools() {
                        new_expected=bdepend
                fi
 
-               if [[ ${expected} && ${new_expected} != ${expected} ]]; then
-                       if [[ ${expected}${new_expected} == 
[br]depend[br]depend ]]
-                       then
-                               # packages can have scripts that are installed
-                               # conditionally to implementation
-                               expected=rdepend
-                       else
-                               integrity_error_new=${new_expected}
-                               return 1
-                       fi
-               else
-                       expected=${new_expected}
+               if ! has "${new_expected}" "${expected[@]}"; then
+                       expected+=( "${new_expected[@]}" )
                fi
        done < <(find "${sitedir}" -name '*.egg-info' -print0)
 }
@@ -49,21 +37,32 @@ distutils_use_setuptools_check() {
        # pyproject.toml is verified by using it
        [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]] && return
 
-       local expected integrity_error_new
+       local expected=()
        _distutils-r1_run_foreach_impl get_expected_distutils_use_setuptools
 
-       if [[ ${integrity_error_new} ]]; then
-               eerror "DISTUTILS_USE_SETUPTOOLS integrity error!"
-               eerror "expected was:    ${expected}"
-               eerror "new_expected is: ${integrity_error_new}"
+       # 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
+               # '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@"
-       elif [[ ${DISTUTILS_USE_SETUPTOOLS} != ${expected} ]]; then
-                       local def=
-                       [[ ${DISTUTILS_USE_SETUPTOOLS} == bdepend ]] && def=' 
(or unset)'
+       else
+               # bdepend+rdepend=rdepend
+               has rdepend "${expected[@]}" && expected=( rdepend )
+               # at this point, expected should have exactly one value
+               [[ ${#expected[@]} -eq 1 ]] || die "integrity error"
 
-                       eqawarn "DISTUTILS_USE_SETUPTOOLS value is probably 
incorrect"
-                       eqawarn "  have:     
DISTUTILS_USE_SETUPTOOLS=${DISTUTILS_USE_SETUPTOOLS}${def}"
-                       eqawarn "  expected: 
DISTUTILS_USE_SETUPTOOLS=${expected}"
+               if [[ ${DISTUTILS_USE_SETUPTOOLS} != ${expected} ]]; then
+                               local def=
+                               [[ ${DISTUTILS_USE_SETUPTOOLS} == bdepend ]] && 
def=' (or unset)'
+
+                               eqawarn "DISTUTILS_USE_SETUPTOOLS value is 
probably incorrect"
+                               eqawarn "  have:     
DISTUTILS_USE_SETUPTOOLS=${DISTUTILS_USE_SETUPTOOLS}${def}"
+                               eqawarn "  expected: 
DISTUTILS_USE_SETUPTOOLS=${expected}"
+               fi
        fi
 }
 

Reply via email to