distutils-r1.eclass: Sync with Gentoo for Cargo fix

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
This commit is contained in:
James Le Cuirot 2024-07-25 12:31:04 +01:00
parent 0215113af3
commit 5c7dd166b7
No known key found for this signature in database
GPG Key ID: 1226415D00DD3137

View File

@ -204,7 +204,7 @@ esac
# This is an optimization that can avoid the overhead of calling into # This is an optimization that can avoid the overhead of calling into
# the build system in pure Python packages and packages using the stable # the build system in pure Python packages and packages using the stable
# Python ABI. # Python ABI.
DISTUTILS_ALLOW_WHEEL_REUSE=1 : ${DISTUTILS_ALLOW_WHEEL_REUSE=1}
# @ECLASS_VARIABLE: BUILD_DIR # @ECLASS_VARIABLE: BUILD_DIR
# @OUTPUT_VARIABLE # @OUTPUT_VARIABLE
@ -936,6 +936,7 @@ _distutils-r1_print_package_versions() {
# distutils patches and/or quirks. # distutils patches and/or quirks.
distutils-r1_python_prepare_all() { distutils-r1_python_prepare_all() {
debug-print-function ${FUNCNAME} "${@}" debug-print-function ${FUNCNAME} "${@}"
_python_sanity_checks
_distutils-r1_check_all_phase_mismatch _distutils-r1_check_all_phase_mismatch
if [[ ! ${DISTUTILS_OPTIONAL} ]]; then if [[ ! ${DISTUTILS_OPTIONAL} ]]; then
@ -1251,7 +1252,9 @@ distutils_pep517_install() {
die "mydistutilsargs are banned in PEP517 mode (use DISTUTILS_ARGS)" die "mydistutilsargs are banned in PEP517 mode (use DISTUTILS_ARGS)"
fi fi
local config_settings= local cmd=() config_settings=
has cargo ${INHERITED} && cmd+=( cargo_env )
case ${DISTUTILS_USE_PEP517} in case ${DISTUTILS_USE_PEP517} in
maturin) maturin)
# `maturin pep517 build-wheel --help` for options # `maturin pep517 build-wheel --help` for options
@ -1388,9 +1391,14 @@ distutils_pep517_install() {
;; ;;
esac esac
# https://pyo3.rs/latest/building-and-distribution.html#cross-compiling
if tc-is-cross-compiler; then
local -x PYO3_CROSS_LIB_DIR=${SYSROOT}/$(python_get_stdlib)
fi
local build_backend=$(_distutils-r1_get_backend) local build_backend=$(_distutils-r1_get_backend)
einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}" einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}"
local cmd=( cmd+=(
"${EPYTHON}" -m gpep517 build-wheel "${EPYTHON}" -m gpep517 build-wheel
--prefix="${EPREFIX}/usr" --prefix="${EPREFIX}/usr"
--backend "${build_backend}" --backend "${build_backend}"
@ -1792,16 +1800,6 @@ distutils-r1_run_phase() {
# bug fixes from Cython (this works only when setup.py is using # bug fixes from Cython (this works only when setup.py is using
# cythonize() but it's better than nothing) # cythonize() but it's better than nothing)
local -x CYTHON_FORCE_REGEN=1 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 fi
# silence warnings when pydevd is loaded on Python 3.11+ # silence warnings when pydevd is loaded on Python 3.11+