Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Tue, 07 Jun 2022 06:55:28
Message-Id: 1654584829.e897148019dc484622c8c6a44153dd45694d8a99.mgorny@gentoo
1 commit: e897148019dc484622c8c6a44153dd45694d8a99
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 26 09:40:58 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Jun 7 06:53:49 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e8971480
7
8 distutils-r1.eclass: Introduce DISTUTILS_USE_PEP517=no mode
9
10 Introduce a new DISTUTILS_USE_PEP517 value "no" that stands for
11 "no build system". This is primarily meant to replace the legacy
12 distutils-r1 logic used for bootstrapping baseline PEP 517 packages.
13 At the same time, it provides a convenient replacement for some
14 of the uses of python-r1.
15
16 In this mode, the eclass does not add PEP517-specific dependencies
17 and does not export default python_compile() and python_install()
18 implementations. However, it does set dependencies, REQUIRED_USE
19 and enables sub-phase usage (with respect to DISTUTILS_OPTIONAL).
20 It also permits using distutils_enable_{sphinx,tests}.
21
22 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
23
24 eclass/distutils-r1.eclass | 30 +++++++++++++++++++++++++++++-
25 1 file changed, 29 insertions(+), 1 deletion(-)
26
27 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
28 index 208bd2718cb8..30f7d941f0d4 100644
29 --- a/eclass/distutils-r1.eclass
30 +++ b/eclass/distutils-r1.eclass
31 @@ -106,6 +106,8 @@ esac
32 #
33 # - maturin - maturin backend
34 #
35 +# - no - no PEP517 build system (see below)
36 +#
37 # - pbr - pbr backend
38 #
39 # - pdm - pdm.pep517 backend
40 @@ -121,6 +123,17 @@ esac
41 #
42 # The variable needs to be set before the inherit line. The eclass
43 # adds appropriate build-time dependencies and verifies the value.
44 +#
45 +# The special value "no" indicates that the package has no build system.
46 +# This is not equivalent to unset DISTUTILS_USE_PEP517 (legacy mode).
47 +# It causes the eclass not to include any build system dependencies
48 +# and to disable default python_compile() and python_install()
49 +# implementations. Baseline Python deps and phase functions will still
50 +# be set (depending on the value of DISTUTILS_OPTIONAL). Most of
51 +# the other eclass functions will work. Testing venv will be provided
52 +# in ${BUILD_DIR}/install after python_compile(), and if any (other)
53 +# files are found in ${BUILD_DIR}/install after python_install(), they
54 +# will be merged into ${D}.
55
56 # @ECLASS_VARIABLE: DISTUTILS_USE_SETUPTOOLS
57 # @DEFAULT_UNSET
58 @@ -212,6 +225,10 @@ _distutils_set_globals() {
59 bdep+='
60 >=dev-util/maturin-0.12.7[${PYTHON_USEDEP}]'
61 ;;
62 + no)
63 + # undo the generic deps added above
64 + bdep=
65 + ;;
66 pbr)
67 bdep+='
68 >=dev-python/pbr-5.8.0-r1[${PYTHON_USEDEP}]'
69 @@ -789,7 +806,7 @@ distutils_install_for_testing() {
70 distutils_write_namespace() {
71 debug-print-function ${FUNCNAME} "${@}"
72
73 - if [[ ! ${DISTUTILS_USE_PEP517} ]]; then
74 + if [[ ! ${DISTUTILS_USE_PEP517:-no} != no ]]; then
75 die "${FUNCNAME} is available only in PEP517 mode"
76 fi
77 if [[ ${EBUILD_PHASE} != test || ! ${BUILD_DIR} ]]; then
78 @@ -912,6 +929,9 @@ _distutils-r1_print_package_versions() {
79 dev-util/maturin
80 )
81 ;;
82 + no)
83 + return
84 + ;;
85 pbr)
86 packages+=(
87 dev-python/pbr
88 @@ -1207,6 +1227,10 @@ distutils_pep517_install() {
89 debug-print-function ${FUNCNAME} "${@}"
90 [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: root"
91
92 + if [[ ! ${DISTUTILS_USE_PEP517:-no} != no ]]; then
93 + die "${FUNCNAME} is available only in PEP517 mode"
94 + fi
95 +
96 local root=${1}
97 local -x WHEEL_BUILD_DIR=${BUILD_DIR}/wheel
98 mkdir -p "${WHEEL_BUILD_DIR}" || die
99 @@ -1351,6 +1375,9 @@ distutils-r1_python_compile() {
100 in_iuse debug && use debug &&
101 MATURIN_PEP517_ARGS+=" --cargo-extra-args=--profile=dev"
102 ;;
103 + no)
104 + return
105 + ;;
106 esac
107
108 if [[ ${DISTUTILS_USE_PEP517} ]]; then
109 @@ -1472,6 +1499,7 @@ distutils-r1_python_test() {
110 distutils-r1_python_install() {
111 debug-print-function ${FUNCNAME} "${@}"
112
113 + [[ ${DISTUTILS_USE_PEP517} == no ]] && return
114 _python_check_EPYTHON
115
116 local scriptdir=${EPREFIX}/usr/bin