eclass/distutils-r1: Sync with Gentoo

It's from Gentoo commit 94d7e7e96945ed47e6d3ea6591cf498fd77994b8.
This commit is contained in:
Flatcar Buildbot 2024-03-11 07:13:20 +00:00 committed by Krzesimir Nowak
parent 2aa068119c
commit a04cf778f6

View File

@ -197,6 +197,10 @@ _DISTUTILS_R1_ECLASS=1
inherit flag-o-matic
inherit multibuild multilib multiprocessing ninja-utils toolchain-funcs
if [[ ${DISTUTILS_USE_PEP517} == meson-python ]]; then
inherit meson
fi
if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
inherit python-r1
else
@ -1386,9 +1390,19 @@ distutils_pep517_install() {
)
;;
meson-python)
# variables defined by setup_meson_src_configure
local MESONARGS=() BOOST_INCLUDEDIR BOOST_LIBRARYDIR NM READELF
# it also calls filter-lto
local x
for x in $(all-flag-vars); do
local -x "${x}=${!x}"
done
setup_meson_src_configure "${DISTUTILS_ARGS[@]}"
local -x NINJAOPTS=$(get_NINJAOPTS)
config_settings=$(
"${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die
"${EPYTHON}" - "${MESONARGS[@]}" <<-EOF || die
import json
import os
import shlex
@ -1812,28 +1826,33 @@ distutils-r1_run_phase() {
local -x AR=${AR} CC=${CC} CPP=${CPP} CXX=${CXX}
tc-export AR CC CPP CXX
if [[ ${DISTUTILS_EXT} ]]; then
if [[ ${BDEPEND} == *dev-python/cython* ]] ; then
# Workaround for https://github.com/cython/cython/issues/2747 (bug #918983)
local -x CFLAGS="${CFLAGS} $(test-flags-CC -Wno-error=incompatible-pointer-types)"
fi
# Perform additional environment modifications only for python_compile
# phase. This is the only phase where we expect to be calling the Python
# build system. We want to localize the altered variables to avoid them
# leaking to other parts of multi-language ebuilds. However, we want
# to avoid localizing them in other phases, particularly
# python_configure_all, where the ebuild may wish to alter them globally.
if [[ ${DISTUTILS_EXT} && ( ${1} == *compile* || ${1} == *test* ) ]]; then
local -x CPPFLAGS="${CPPFLAGS} $(usex debug '-UNDEBUG' '-DNDEBUG')"
# always generate .c files from .pyx files to ensure we get latest
# bug fixes from Cython (this works only when setup.py is using
# cythonize() but it's better than nothing)
local -x CYTHON_FORCE_REGEN=1
# Rust extensions are incompatible with C/C++ LTO compiler
# see e.g. https://bugs.gentoo.org/910220
if has cargo ${INHERITED}; then
local x
for x in $(all-flag-vars); do
local -x "${x}=${!x}"
done
filter-lto
fi
fi
# silence warnings when pydevd is loaded on Python 3.11+
local -x PYDEVD_DISABLE_FILE_VALIDATION=1
# Rust extensions are incompatible with C/C++ LTO compiler
# see e.g. https://bugs.gentoo.org/910220
if has cargo ${INHERITED}; then
filter-lto
fi
# How to build Python modules in different worlds...
local ldopts
case "${CHOST}" in