diff options
Diffstat (limited to 'eclass/distutils-r1.eclass')
-rw-r--r-- | eclass/distutils-r1.eclass | 91 |
1 files changed, 57 insertions, 34 deletions
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index e1672dd3c3b0..62e092b6231f 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -134,13 +134,20 @@ # # - sip - sipbuild backend # -# - standalone - standalone build systems without external deps -# (used for bootstrapping). +# - standalone - standalone/local build systems # # - uv-build - uv-build backend (using dev-python/uv) # -# The variable needs to be set before the inherit line. The eclass -# adds appropriate build-time dependencies and verifies the value. +# The variable needs to be set before the inherit line. If another +# value than "standalone" and "no" is used, The eclass adds appropriate +# build-time dependencies, verifies the value and calls the appropriate +# modern entry point for the backend. With DISTUTILS_UPSTREAM_PEP517, +# this variable can be used to override the upstream build backend. +# +# The value of "standalone" indicates that upstream is using a custom, +# local build backend. In this mode, the eclass does not add any +# dependencies, disables build backend verification and uses the exact +# entry point listed in pyproject.toml. # # The special value "no" indicates that the package has no build system. # This is not equivalent to unset DISTUTILS_USE_PEP517 (legacy mode). @@ -154,18 +161,24 @@ # will be merged into ${D}. # @ECLASS_VARIABLE: DISTUTILS_UPSTREAM_PEP517 +# @DEFAULT_UNSET # @DESCRIPTION: # Specifies the PEP517 build backend used upstream. It is used # 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 # to build the wheel using other backend than the one used upstream. # +# When using it, ideally it should list the build backend actually used +# upstream, so the eclass will throw an error if that backend changes +# (and therefore overrides may need to change as well). As a special +# case, setting it to "standalone" disables the check entirely (while +# still forcing the backend, unlike DISTUTILS_USE_PEP517=standalone). +# # Please note that even in packages using PEP621 metadata, there can # be subtle differences between the behavior of different PEP517 build # backends, for example regarding finding package files. When using # this option, please make sure that the package is installed correctly. -: "${DISTUTILS_UPSTREAM_PEP517:=${DISTUTILS_USE_PEP517}}" # @ECLASS_VARIABLE: DISTUTILS_USE_SETUPTOOLS # @DEFAULT_UNSET @@ -215,7 +228,7 @@ # This is an optimization that can avoid the overhead of calling into # the build system in pure Python packages and packages using the stable # Python ABI. -: ${DISTUTILS_ALLOW_WHEEL_REUSE=1} +: "${DISTUTILS_ALLOW_WHEEL_REUSE=1}" # @ECLASS_VARIABLE: BUILD_DIR # @OUTPUT_VARIABLE @@ -322,7 +335,7 @@ _distutils_set_globals() { ;; setuptools) bdep+=' - >=dev-python/setuptools-75.8.2[${PYTHON_USEDEP}] + >=dev-python/setuptools-78.1.0[${PYTHON_USEDEP}] ' ;; sip) @@ -347,7 +360,7 @@ _distutils_set_globals() { eqawarn "is enabled." fi 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 no|manual) @@ -388,6 +401,11 @@ _distutils_set_globals() { DISTUTILS_DEPS=${bdep} readonly DISTUTILS_DEPS 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 if [[ ! ${DISTUTILS_OPTIONAL} ]]; then @@ -599,7 +617,7 @@ distutils_enable_sphinx() { # # - 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 # @@ -645,14 +663,10 @@ distutils_enable_tests() { fi ;; 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-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}" @@ -981,15 +995,6 @@ distutils-r1_python_prepare_all() { if [[ ! ${DISTUTILS_USE_PEP517} ]]; then _distutils-r1_disable_ez_setup _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 if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]] @@ -1158,13 +1163,28 @@ _distutils-r1_get_backend() { fi fi + # if DISTUTILS_USE_PEP517 is "standalone", we respect the exact + # backend used in pyproject.toml; otherwise we force the backend + # based on DISTUTILS_USE_PEP517 if [[ ${DISTUTILS_USE_PEP517} == standalone ]]; then echo "${build_backend}" return fi + # we can output it early, even if we die below + echo "$(_distutils-r1_key_to_backend "${DISTUTILS_USE_PEP517}")" + + # skip backend verification if DISTUTILS_UPSTREAM_PEP517 + # is "standalone" + if [[ ${DISTUTILS_UPSTREAM_PEP517} == standalone ]]; then + return + fi + # 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 # special-case deprecated backends case ${build_backend} in @@ -1188,14 +1208,12 @@ _distutils-r1_get_backend() { # if we didn't die, we're dealing with a deprecated backend 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 "The project should use ${expected_backend} instead." > "${T}"/.distutils_deprecated_backend_warned || die fi fi - - echo "$(_distutils-r1_key_to_backend "${DISTUTILS_USE_PEP517}")" } # @FUNCTION: distutils_wheel_install @@ -1667,7 +1685,8 @@ distutils-r1_python_install() { # let's explicitly verify these assumptions # remove files that we've created explicitly - rm "${reg_scriptdir}"/{"${EPYTHON}",python3,python,pyvenv.cfg} || die + rm "${reg_scriptdir}"/{"${EPYTHON}",python3,python} || die + rm "${reg_scriptdir}"/../pyvenv.cfg || die # Automagically do the QA check to avoid issues when bootstrapping # prefix. @@ -1722,7 +1741,6 @@ distutils-r1_python_install() { # python likes to compile any module it sees, which triggers sandbox # failures if some packages haven't compiled their modules yet. addpredict "${EPREFIX}/usr/lib/${EPYTHON}" - addpredict "${EPREFIX}/usr/lib/pypy3.10" addpredict "${EPREFIX}/usr/local" # bug 498232 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then @@ -1996,7 +2014,7 @@ _distutils-r1_compare_installed_files() { --exclude="*$(get_modname)" \ "${_DISTUTILS_PREVIOUS_SITE}" "${sitedir}" 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 "this message." fi @@ -2036,7 +2054,12 @@ _distutils-r1_post_python_compile() { ln -s "${PYTHON}" "${bindir}/${EPYTHON}" || die ln -s "${EPYTHON}" "${bindir}/python3" || die ln -s "${EPYTHON}" "${bindir}/python" || die - cat > "${bindir}"/pyvenv.cfg <<-EOF || die + # python3.14 changed venv logic so that: + # 1) pyvenv.cfg location explicitly determines prefix + # (i.e. we no longer can be put in bin/) + # 2) "home =" key must be present + cat > "${bindir}"/../pyvenv.cfg <<-EOF || die + home = ${EPREFIX}/usr/bin include-system-site-packages = true EOF @@ -2187,7 +2210,7 @@ _distutils-r1_post_python_install() { if [[ ! ${DISTUTILS_EXT} && ! ${_DISTUTILS_EXT_WARNED} ]]; then if [[ $(find "${sitedir}" -name "*$(get_modname)" | head -n 1) ]] 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 "in the ebuild." _DISTUTILS_EXT_WARNED=1 |