eclass/distutils-r1: Sync with Gentoo

It's from Gentoo commit 970679b8be00a13d0fc71c2cfda6e9ecd5cd7fdf.
This commit is contained in:
Flatcar Buildbot 2023-06-05 07:12:48 +00:00
parent cc2a8a76fc
commit 34df514673

View File

@ -125,6 +125,8 @@ esac
# #
# - pdm - pdm.pep517 backend # - pdm - pdm.pep517 backend
# #
# - pdm-backend - pdm.backend backend
#
# - poetry - poetry-core backend # - poetry - poetry-core backend
# #
# - setuptools - distutils or setuptools (incl. legacy mode) # - setuptools - distutils or setuptools (incl. legacy mode)
@ -220,7 +222,7 @@ _distutils_set_globals() {
;; ;;
hatchling) hatchling)
bdep+=' bdep+='
>=dev-python/hatchling-1.12.2[${PYTHON_USEDEP}] >=dev-python/hatchling-1.17.0[${PYTHON_USEDEP}]
' '
;; ;;
jupyter) jupyter)
@ -230,7 +232,7 @@ _distutils_set_globals() {
;; ;;
maturin) maturin)
bdep+=' bdep+='
>=dev-util/maturin-0.14.10[${PYTHON_USEDEP}] >=dev-util/maturin-1.0.1[${PYTHON_USEDEP}]
' '
;; ;;
no) no)
@ -239,7 +241,7 @@ _distutils_set_globals() {
;; ;;
meson-python) meson-python)
bdep+=' bdep+='
>=dev-python/meson-python-0.12.0[${PYTHON_USEDEP}] >=dev-python/meson-python-0.13.1[${PYTHON_USEDEP}]
' '
;; ;;
pbr) pbr)
@ -249,23 +251,28 @@ _distutils_set_globals() {
;; ;;
pdm) pdm)
bdep+=' bdep+='
>=dev-python/pdm-pep517-1.0.6[${PYTHON_USEDEP}] >=dev-python/pdm-pep517-1.1.4[${PYTHON_USEDEP}]
'
;;
pdm-backend)
bdep+='
>=dev-python/pdm-backend-2.0.7[${PYTHON_USEDEP}]
' '
;; ;;
poetry) poetry)
bdep+=' bdep+='
>=dev-python/poetry-core-1.4.0[${PYTHON_USEDEP}] >=dev-python/poetry-core-1.5.2[${PYTHON_USEDEP}]
' '
;; ;;
setuptools) setuptools)
bdep+=' bdep+='
>=dev-python/setuptools-67.2.0[${PYTHON_USEDEP}] >=dev-python/setuptools-67.7.2[${PYTHON_USEDEP}]
>=dev-python/wheel-0.38.4[${PYTHON_USEDEP}] >=dev-python/wheel-0.40.0[${PYTHON_USEDEP}]
' '
;; ;;
sip) sip)
bdep+=' bdep+='
>=dev-python/sip-6.7.5-r1[${PYTHON_USEDEP}] >=dev-python/sip-6.7.8[${PYTHON_USEDEP}]
' '
;; ;;
standalone) standalone)
@ -600,12 +607,12 @@ distutils_enable_tests() {
test_pkg=">=dev-python/nose-1.3.7_p20221026" test_pkg=">=dev-python/nose-1.3.7_p20221026"
;; ;;
pytest) pytest)
test_pkg=">=dev-python/pytest-7.2.1" test_pkg=">=dev-python/pytest-7.3.1"
;; ;;
setup.py) setup.py)
;; ;;
unittest) unittest)
test_pkg="dev-python/unittest-or-fail" # dep handled below
;; ;;
*) *)
die "${FUNCNAME}: unsupported argument: ${1}" die "${FUNCNAME}: unsupported argument: ${1}"
@ -623,6 +630,13 @@ distutils_enable_tests() {
${test_pkg}[\${PYTHON_USEDEP}] ${test_pkg}[\${PYTHON_USEDEP}]
")" ")"
fi fi
elif [[ ${1} == unittest ]]; then
# unittest-or-fail is needed in py<3.12
test_deps+="
$(python_gen_cond_dep '
dev-python/unittest-or-fail[${PYTHON_USEDEP}]
' 3.{9..11})
"
fi fi
if [[ -n ${test_deps} ]]; then if [[ -n ${test_deps} ]]; then
IUSE+=" test" IUSE+=" test"
@ -918,6 +932,11 @@ _distutils-r1_print_package_versions() {
dev-python/gpep517 dev-python/gpep517
dev-python/installer dev-python/installer
) )
if [[ ${DISTUTILS_EXT} ]]; then
packages+=(
dev-python/cython
)
fi
case ${DISTUTILS_USE_PEP517} in case ${DISTUTILS_USE_PEP517} in
flit) flit)
packages+=( packages+=(
@ -972,6 +991,12 @@ _distutils-r1_print_package_versions() {
dev-python/setuptools dev-python/setuptools
) )
;; ;;
pdm-backend)
packages+=(
dev-python/pdm-backend
dev-python/setuptools
)
;;
poetry) poetry)
packages+=( packages+=(
dev-python/poetry-core dev-python/poetry-core
@ -1166,6 +1191,9 @@ _distutils-r1_backend_to_key() {
pbr.build) pbr.build)
echo pbr echo pbr
;; ;;
pdm.backend)
echo pdm-backend
;;
pdm.pep517.api) pdm.pep517.api)
echo pdm echo pdm
;; ;;
@ -1318,44 +1346,40 @@ distutils_pep517_install() {
local config_settings= local config_settings=
case ${DISTUTILS_USE_PEP517} in case ${DISTUTILS_USE_PEP517} in
maturin)
# `maturin pep517 build-wheel --help` for options
local maturin_args=(
"${DISTUTILS_ARGS[@]}"
--jobs="$(makeopts_jobs)"
--skip-auditwheel # see bug #831171
$(in_iuse debug && usex debug '--profile=dev' '')
)
config_settings=$(
"${EPYTHON}" - "${maturin_args[@]}" <<-EOF || die
import json
import sys
print(json.dumps({"build-args": sys.argv[1:]}))
EOF
)
;;
meson-python) meson-python)
local -x NINJAOPTS=$(get_NINJAOPTS) local -x NINJAOPTS=$(get_NINJAOPTS)
if has_version -b '>=dev-python/meson-python-0.13'; then config_settings=$(
config_settings=$( "${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die
"${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die import json
import json import os
import os import shlex
import shlex import sys
import sys
ninjaopts = shlex.split(os.environ["NINJAOPTS"]) ninjaopts = shlex.split(os.environ["NINJAOPTS"])
print(json.dumps({ print(json.dumps({
"builddir": "${BUILD_DIR}", "builddir": "${BUILD_DIR}",
"setup-args": sys.argv[1:], "setup-args": sys.argv[1:],
"compile-args": ["-v"] + ninjaopts, "compile-args": ["-v"] + ninjaopts,
})) }))
EOF EOF
) )
else
config_settings=$(
"${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die
import json
import os
import shlex
import sys
ninjaopts = shlex.split(os.environ["NINJAOPTS"])
print(json.dumps({
"builddir": "${BUILD_DIR}",
"setup-args": sys.argv[1:],
"compile-args": [
"-v",
f"--ninja-args={ninjaopts!r}",
],
}))
EOF
)
fi
;; ;;
setuptools) setuptools)
if [[ -n ${DISTUTILS_ARGS[@]} ]]; then if [[ -n ${DISTUTILS_ARGS[@]} ]]; then
@ -1492,15 +1516,6 @@ distutils-r1_python_compile() {
esetup.py build -j "${jobs}" "${@}" esetup.py build -j "${jobs}" "${@}"
fi fi
;; ;;
maturin)
# auditwheel may auto-bundle libraries (bug #831171),
# also support cargo.eclass' IUSE=debug if available
local -x MATURIN_PEP517_ARGS="
--jobs=$(makeopts_jobs)
--skip-auditwheel
$(in_iuse debug && usex debug --profile=dev '')
"
;;
no) no)
return return
;; ;;
@ -1780,9 +1795,11 @@ distutils-r1_run_phase() {
# and _all() already localizes it # and _all() already localizes it
local -x PATH=${PATH} local -x PATH=${PATH}
# Undo the default switch in setuptools-60+ for the time being, if _python_impl_matches "${EPYTHON}" 3.{9..11}; then
# to avoid replacing .egg-info file with directory in-place. # Undo the default switch in setuptools-60+ for the time being,
local -x SETUPTOOLS_USE_DISTUTILS="${SETUPTOOLS_USE_DISTUTILS:-stdlib}" # to avoid replacing .egg-info file with directory in-place.
local -x SETUPTOOLS_USE_DISTUTILS="${SETUPTOOLS_USE_DISTUTILS:-stdlib}"
fi
# Bug 559644 # Bug 559644
# using PYTHONPATH when the ${BUILD_DIR}/lib is not created yet might lead to # using PYTHONPATH when the ${BUILD_DIR}/lib is not created yet might lead to
@ -1799,13 +1816,15 @@ distutils-r1_run_phase() {
if [[ ${DISTUTILS_EXT} ]]; then if [[ ${DISTUTILS_EXT} ]]; then
local -x CPPFLAGS="${CPPFLAGS} $(usex debug '-UNDEBUG' '-DNDEBUG')" 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
fi fi
# How to build Python modules in different worlds... # How to build Python modules in different worlds...
local ldopts local ldopts
case "${CHOST}" in case "${CHOST}" in
# provided by haubi, 2014-07-08
*-aix*) ldopts='-shared -Wl,-berok';; # good enough
# provided by grobian, 2014-06-22, bug #513664 c7 # provided by grobian, 2014-06-22, bug #513664 c7
*-darwin*) ldopts='-bundle -undefined dynamic_lookup';; *-darwin*) ldopts='-bundle -undefined dynamic_lookup';;
*) ldopts='-shared';; *) ldopts='-shared';;