eclass/distutils-r1: Sync with Gentoo

It's from Gentoo commit 32bbaebe4b727997e483d6b78c8d71cf9fde6b7e.
This commit is contained in:
Flatcar Buildbot 2025-04-28 07:14:47 +00:00
parent ba19252ad1
commit 5b68190314

View File

@ -154,10 +154,11 @@
# will be merged into ${D}. # will be merged into ${D}.
# @ECLASS_VARIABLE: DISTUTILS_UPSTREAM_PEP517 # @ECLASS_VARIABLE: DISTUTILS_UPSTREAM_PEP517
# @DEFAULT_UNSET
# @DESCRIPTION: # @DESCRIPTION:
# Specifies the PEP517 build backend used upstream. It is used # Specifies the PEP517 build backend used upstream. It is used
# by the eclass to verify the correctness of DISTUTILS_USE_PEP517, # by the eclass to verify the correctness of DISTUTILS_USE_PEP517,
# and matches DISTUTILS_USE_PEP517 by default. However, it can be # and defaults to ${DISTUTILS_USE_PEP517}. However, it can be
# overriden to workaround the eclass check, when it is desirable # overriden to workaround the eclass check, when it is desirable
# to build the wheel using other backend than the one used upstream. # to build the wheel using other backend than the one used upstream.
# #
@ -165,7 +166,6 @@
# be subtle differences between the behavior of different PEP517 build # be subtle differences between the behavior of different PEP517 build
# backends, for example regarding finding package files. When using # backends, for example regarding finding package files. When using
# this option, please make sure that the package is installed correctly. # this option, please make sure that the package is installed correctly.
: "${DISTUTILS_UPSTREAM_PEP517:=${DISTUTILS_USE_PEP517}}"
# @ECLASS_VARIABLE: DISTUTILS_USE_SETUPTOOLS # @ECLASS_VARIABLE: DISTUTILS_USE_SETUPTOOLS
# @DEFAULT_UNSET # @DEFAULT_UNSET
@ -322,7 +322,7 @@ _distutils_set_globals() {
;; ;;
setuptools) setuptools)
bdep+=' bdep+='
>=dev-python/setuptools-75.8.2[${PYTHON_USEDEP}] >=dev-python/setuptools-78.1.0[${PYTHON_USEDEP}]
' '
;; ;;
sip) sip)
@ -347,7 +347,7 @@ _distutils_set_globals() {
eqawarn "is enabled." eqawarn "is enabled."
fi fi
else else
local setuptools_dep='>=dev-python/setuptools-75.8.2[${PYTHON_USEDEP}]' local setuptools_dep='>=dev-python/setuptools-78.1.0[${PYTHON_USEDEP}]'
case ${DISTUTILS_USE_SETUPTOOLS:-bdepend} in case ${DISTUTILS_USE_SETUPTOOLS:-bdepend} in
no|manual) no|manual)
@ -388,6 +388,11 @@ _distutils_set_globals() {
DISTUTILS_DEPS=${bdep} DISTUTILS_DEPS=${bdep}
readonly DISTUTILS_DEPS readonly DISTUTILS_DEPS
fi fi
else
eqawarn "QA Notice: distutils-r1.eclass legacy mode is deprecated and will be removed."
eqawarn "Please migrate your ebuilds to use DISTUTILS_USE_PEP517 (common values"
eqawarn "are 'setuptools' for packages using setuptools/distutils,"
eqawarn "and 'no' for packages using non-PEP517 build systems)."
fi fi
if [[ ! ${DISTUTILS_OPTIONAL} ]]; then if [[ ! ${DISTUTILS_OPTIONAL} ]]; then
@ -599,7 +604,7 @@ distutils_enable_sphinx() {
# #
# - pytest: dev-python/pytest # - pytest: dev-python/pytest
# #
# - setup.py: setup.py test (no deps included) # - setup.py: setup.py test (no deps included; deprecated)
# #
# - unittest: for built-in Python unittest module # - unittest: for built-in Python unittest module
# #
@ -645,14 +650,10 @@ distutils_enable_tests() {
fi fi
;; ;;
setup.py) setup.py)
eqawarn "QA Notice: 'distutils_enable_tests setup.py' is deprecated and will be removed."
eqawarn "Please use unittest or pytest instead."
;; ;;
unittest) unittest)
# unittest-or-fail is needed in py<3.12
local test_pkgs="$(python_gen_cond_dep '
dev-python/unittest-or-fail[${PYTHON_USEDEP}]
' 3.10 3.11
)"
[[ -n ${test_pkgs} ]] && test_deps+=" ${test_pkgs}"
;; ;;
*) *)
die "${FUNCNAME}: unsupported argument: ${1}" die "${FUNCNAME}: unsupported argument: ${1}"
@ -981,15 +982,6 @@ distutils-r1_python_prepare_all() {
if [[ ! ${DISTUTILS_USE_PEP517} ]]; then if [[ ! ${DISTUTILS_USE_PEP517} ]]; then
_distutils-r1_disable_ez_setup _distutils-r1_disable_ez_setup
_distutils-r1_handle_pyproject_toml _distutils-r1_handle_pyproject_toml
case ${DISTUTILS_USE_SETUPTOOLS} in
no)
eqawarn "Non-PEP517 builds are deprecated for ebuilds using plain distutils."
eqawarn "Please migrate to DISTUTILS_USE_PEP517=setuptools."
eqawarn "Please see Python Guide for more details:"
eqawarn " https://projects.gentoo.org/python/guide/distutils.html"
;;
esac
fi fi
if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]] if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
@ -1164,7 +1156,10 @@ _distutils-r1_get_backend() {
fi fi
# verify that the ebuild correctly specifies the build backend # verify that the ebuild correctly specifies the build backend
local expected_backend=$(_distutils-r1_key_to_backend "${DISTUTILS_UPSTREAM_PEP517}") local expected_backend=$(
_distutils-r1_key_to_backend \
"${DISTUTILS_UPSTREAM_PEP517:-${DISTUTILS_USE_PEP517}}"
)
if [[ ${expected_backend} != ${build_backend} ]]; then if [[ ${expected_backend} != ${build_backend} ]]; then
# special-case deprecated backends # special-case deprecated backends
case ${build_backend} in case ${build_backend} in
@ -1188,7 +1183,7 @@ _distutils-r1_get_backend() {
# if we didn't die, we're dealing with a deprecated backend # if we didn't die, we're dealing with a deprecated backend
if [[ ! -f ${T}/.distutils_deprecated_backend_warned ]]; then if [[ ! -f ${T}/.distutils_deprecated_backend_warned ]]; then
eqawarn "${build_backend} backend is deprecated. Please see:" eqawarn "QA Notice: ${build_backend} backend is deprecated. Please see:"
eqawarn "https://projects.gentoo.org/python/guide/qawarn.html#deprecated-pep-517-backends" eqawarn "https://projects.gentoo.org/python/guide/qawarn.html#deprecated-pep-517-backends"
eqawarn "The project should use ${expected_backend} instead." eqawarn "The project should use ${expected_backend} instead."
> "${T}"/.distutils_deprecated_backend_warned || die > "${T}"/.distutils_deprecated_backend_warned || die
@ -1996,7 +1991,7 @@ _distutils-r1_compare_installed_files() {
--exclude="*$(get_modname)" \ --exclude="*$(get_modname)" \
"${_DISTUTILS_PREVIOUS_SITE}" "${sitedir}" "${_DISTUTILS_PREVIOUS_SITE}" "${sitedir}"
if [[ ${?} -ne 0 ]]; then if [[ ${?} -ne 0 ]]; then
eqawarn "Package creating at least one pure Python wheel installs different" eqawarn "QA Notice: Package creating at least one pure Python wheel installs different"
eqawarn "Python files between implementations. See diff in build log, above" eqawarn "Python files between implementations. See diff in build log, above"
eqawarn "this message." eqawarn "this message."
fi fi
@ -2187,7 +2182,7 @@ _distutils-r1_post_python_install() {
if [[ ! ${DISTUTILS_EXT} && ! ${_DISTUTILS_EXT_WARNED} ]]; then if [[ ! ${DISTUTILS_EXT} && ! ${_DISTUTILS_EXT_WARNED} ]]; then
if [[ $(find "${sitedir}" -name "*$(get_modname)" | head -n 1) ]] if [[ $(find "${sitedir}" -name "*$(get_modname)" | head -n 1) ]]
then then
eqawarn "Python extension modules (*$(get_modname)) found installed. Please set:" eqawarn "QA Notice: Python extension modules (*$(get_modname)) found installed. Please set:"
eqawarn " DISTUTILS_EXT=1" eqawarn " DISTUTILS_EXT=1"
eqawarn "in the ebuild." eqawarn "in the ebuild."
_DISTUTILS_EXT_WARNED=1 _DISTUTILS_EXT_WARNED=1