diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2020-09-23 10:22:15 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2020-09-23 10:22:15 +0100 |
commit | 8b4ace9c50842c5b83401ea7b179dcab940387e1 (patch) | |
tree | 230f3135ceaace633cf93e9838b185c4a6664c2e /metadata/install-qa-check.d | |
parent | 9ee6d97c2883d42f204a533a8bc1f4562df778fb (diff) |
gentoo resync : 23.09.2020
Diffstat (limited to 'metadata/install-qa-check.d')
-rw-r--r-- | metadata/install-qa-check.d/60distutils-use-setuptools | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/metadata/install-qa-check.d/60distutils-use-setuptools b/metadata/install-qa-check.d/60distutils-use-setuptools new file mode 100644 index 000000000000..698d832800f7 --- /dev/null +++ b/metadata/install-qa-check.d/60distutils-use-setuptools @@ -0,0 +1,76 @@ +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# QA check: verify correctness of DISTUTILS_USE_SETUPTOOLS +# Maintainer: Python project <python@gentoo.org> + +distutils_use_setuptools_check() { + # applicable only to ebuilds inheriting distutils-r1 + [[ ${_DISTUTILS_R1} ]] || return + # 'manual' means no checking + [[ ${DISTUTILS_USE_SETUPTOOLS} == manual ]] && return + # pyproject.toml is verified by using it + [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]] && return + + local expected=() + 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[@]} -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 [[ ${#expected[@]} -gt 0 ]]; then + # bdepend+rdepend=rdepend + has rdepend "${expected[@]}" && expected=( rdepend ) + # at this point, expected should have exactly one value + [[ ${#expected[@]} -eq 1 ]] || die "integrity error" + + 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 +} + +distutils_use_setuptools_check + +: # guarantee successful exit + +# vim:ft=ebuild |