You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.3 KiB
104 lines
3.3 KiB
# Copyright 2020-2021 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
|
|
|
|
# setuptools dep is not set if distutils is optional
|
|
if [[ ${DISTUTILS_OPTIONAL} ]]; then
|
|
if [[ ${DISTUTILS_USE_SETUPTOOLS} != bdepend ]]; then
|
|
eerror "QA Notice: DISTUTILS_USE_SETUPTOOLS is not used when DISTUTILS_OPTIONAL"
|
|
eerror "is enabled."
|
|
fi
|
|
return
|
|
fi
|
|
|
|
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 [[ -f ${egg}/requires.txt ]] &&
|
|
grep -q -s '^setuptools' \
|
|
<(sed -e '/^\[/,$d' "${egg}"/requires.txt)
|
|
then
|
|
# explicit *unconditional* rdepend in package metadata
|
|
new_expected=rdepend
|
|
elif grep -q -s '\[\(console\|gui\)_scripts\]' \
|
|
"${egg}"/entry_points.txt
|
|
then
|
|
new_expected=entry-point
|
|
else
|
|
new_expected=bdepend
|
|
fi
|
|
|
|
if ! has "${new_expected}" "${expected[@]}"; then
|
|
expected+=( "${new_expected[@]}" )
|
|
fi
|
|
done < <(find "${sitedir}" -name '*.egg-info' -print0)
|
|
fi
|
|
done
|
|
|
|
if [[ ${#expected[@]} -gt 1 ]] && has no "${expected[@]}"; then
|
|
# 'no' and '[rb]depend' are mutually exclusive
|
|
eerror "QA Notice: The package seems to have used distutils and setuptools"
|
|
eerror "simultaneously"
|
|
eerror ""
|
|
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
|
|
# if we did not find anything, also assume 'no' is desired,
|
|
# we do not want the setuptools dep
|
|
[[ ${#expected[@]} -eq 0 ]] && expected=( no )
|
|
# *+rdepend=rdepend
|
|
has rdepend "${expected[@]}" && expected=( rdepend )
|
|
|
|
if has entry-point "${expected[@]}"; then
|
|
if [[ ${DISTUTILS_STRICT_ENTRY_POINTS} ]]; then
|
|
# option for devs to future-proof their packages
|
|
# please don't let ago enable it
|
|
expected=( bdepend )
|
|
else
|
|
# accept either rdepend or bdepend for the time being
|
|
# but suggest bdepend as the future-proof option
|
|
expected=( bdepend rdepend )
|
|
fi
|
|
fi
|
|
|
|
if ! has ${DISTUTILS_USE_SETUPTOOLS} "${expected[@]}"; then
|
|
local def=
|
|
[[ ${DISTUTILS_USE_SETUPTOOLS} == bdepend ]] && def=' (or unset)'
|
|
|
|
eqawarn "QA Notice: DISTUTILS_USE_SETUPTOOLS value is probably incorrect"
|
|
eqawarn " have: DISTUTILS_USE_SETUPTOOLS=${DISTUTILS_USE_SETUPTOOLS}${def}"
|
|
if [[ ${expected[0]} == bdepend ]]; then
|
|
eqawarn " expected: (unset)"
|
|
else
|
|
eqawarn " expected: DISTUTILS_USE_SETUPTOOLS=${expected[0]}"
|
|
fi
|
|
fi
|
|
fi
|
|
}
|
|
|
|
distutils_use_setuptools_check
|
|
|
|
: # guarantee successful exit
|
|
|
|
# vim:ft=ebuild
|