eclass/python-r1: Sync with Gentoo

It's from Gentoo commit 52eb3fb4e8b3f38c7f22271ee1150c14bfe97cdd.
This commit is contained in:
Krzesimir Nowak 2023-01-24 10:47:40 +01:00
parent cfbf805f6e
commit 179cb46a1d

View File

@ -1,4 +1,4 @@
# Copyright 1999-2022 Gentoo Authors
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: python-r1.eclass
@ -7,8 +7,8 @@
# @AUTHOR:
# Author: Michał Górny <mgorny@gentoo.org>
# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @SUPPORTED_EAPIS: 6 7 8
# @PROVIDES: multibuild python-utils-r1
# @SUPPORTED_EAPIS: 7 8
# @PROVIDES: python-utils-r1
# @BLURB: A common, simple eclass for Python packages.
# @DESCRIPTION:
# A common eclass providing helper functions to build and install
@ -30,29 +30,22 @@
# For more information, please see the Python Guide:
# https://projects.gentoo.org/python/guide/
case "${EAPI:-0}" in
[0-5])
die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
;;
[6-8])
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
case ${EAPI} in
7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ ! ${_PYTHON_R1} ]]; then
if [[ ! ${_PYTHON_R1_ECLASS} ]]; then
_PYTHON_R1_ECLASS=1
if [[ ${_PYTHON_SINGLE_R1} ]]; then
if [[ ${_PYTHON_SINGLE_R1_ECLASS} ]]; then
die 'python-r1.eclass can not be used with python-single-r1.eclass.'
elif [[ ${_PYTHON_ANY_R1} ]]; then
elif [[ ${_PYTHON_ANY_R1_ECLASS} ]]; then
die 'python-r1.eclass can not be used with python-any-r1.eclass.'
fi
inherit multibuild python-utils-r1
fi
# @ECLASS_VARIABLE: PYTHON_COMPAT
# @REQUIRED
# @DESCRIPTION:
@ -243,8 +236,6 @@ _python_set_globals() {
_python_set_globals
unset -f _python_set_globals
if [[ ! ${_PYTHON_R1} ]]; then
# @FUNCTION: _python_validate_useflags
# @INTERNAL
# @DESCRIPTION:
@ -625,6 +616,24 @@ _python_multibuild_wrapper() {
python_foreach_impl() {
debug-print-function ${FUNCNAME} "${@}"
if [[ ${_DISTUTILS_R1} ]]; then
if has "${EBUILD_PHASE}" prepare configure compile test install &&
[[ ! ${_DISTUTILS_CALLING_FOREACH_IMPL} &&
! ${_DISTUTILS_FOREACH_IMPL_WARNED} ]]
then
eqawarn "python_foreach_impl has been called directly while using distutils-r1."
eqawarn "Please redefine python_*() phase functions to meet your expectations"
eqawarn "instead."
_DISTUTILS_FOREACH_IMPL_WARNED=1
if ! has "${EAPI}" 7 8; then
die "Calling python_foreach_impl from distutils-r1 is banned in EAPI ${EAPI}"
fi
fi
# undo the eclass-set value to catch nested calls
local _DISTUTILS_CALLING_FOREACH_IMPL=
fi
local MULTIBUILD_VARIANTS
_python_obtain_impls
@ -710,7 +719,7 @@ python_setup() {
fi
# (reverse iteration -- newest impl first)
local found
local found i
_python_verify_patterns "${@}"
for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do
local impl=${_PYTHON_SUPPORTED_IMPLS[i]}
@ -786,10 +795,9 @@ python_replicate_script() {
local f
for f; do
local dosym=dosym
[[ ${EAPI} == [67] ]] && dosym=dosym8
[[ ${EAPI} == 7 ]] && dosym=dosym8
"${dosym}" -r /usr/lib/python-exec/python-exec2 "${f#${ED}}"
done
}
_PYTHON_R1=1
fi