1 |
Switch the distutils-r1.eclass to gpep517 code branches unconditionally. |
2 |
|
3 |
Signed-off-by: Michał Górny <mgorny@g.o> |
4 |
--- |
5 |
eclass/distutils-r1.eclass | 84 +++++++------------------------------- |
6 |
1 file changed, 15 insertions(+), 69 deletions(-) |
7 |
|
8 |
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass |
9 |
index 49c98290f30f..6fc9f1b9c1ff 100644 |
10 |
--- a/eclass/distutils-r1.eclass |
11 |
+++ b/eclass/distutils-r1.eclass |
12 |
@@ -159,13 +159,6 @@ esac |
13 |
# ${DISTUTILS_DEPS}" |
14 |
# @CODE |
15 |
|
16 |
-# @ECLASS_VARIABLE: GPEP517_TESTING |
17 |
-# @USER_VARIABLE |
18 |
-# @DESCRIPTION: |
19 |
-# Enable in make.conf to test building via dev-python/gpep517 instead of |
20 |
-# inline Python snippets. dev-python/gpep517 needs to be installed |
21 |
-# first. |
22 |
- |
23 |
if [[ ! ${_DISTUTILS_R1} ]]; then |
24 |
|
25 |
[[ ${EAPI} == 6 ]] && inherit eutils xdg-utils |
26 |
@@ -192,11 +185,8 @@ _distutils_set_globals() { |
27 |
die "DISTUTILS_USE_SETUPTOOLS is not used in PEP517 mode" |
28 |
fi |
29 |
|
30 |
- # installer is used to install the wheel |
31 |
- # tomli is used to read build-backend from pyproject.toml |
32 |
bdep=' |
33 |
- >=dev-python/installer-0.4.0_p20220124[${PYTHON_USEDEP}] |
34 |
- >=dev-python/tomli-1.2.3[${PYTHON_USEDEP}]' |
35 |
+ >=dev-python/gpep517-3[${PYTHON_USEDEP}]' |
36 |
case ${DISTUTILS_USE_PEP517} in |
37 |
flit) |
38 |
bdep+=' |
39 |
@@ -1028,20 +1018,7 @@ _distutils-r1_get_backend() { |
40 |
if [[ -f pyproject.toml ]]; then |
41 |
# if pyproject.toml exists, try getting the backend from it |
42 |
# NB: this could fail if pyproject.toml doesn't list one |
43 |
- if [[ ${GPEP517_TESTING} ]]; then |
44 |
- build_backend=$(gpep517 get-backend) |
45 |
- else |
46 |
- build_backend=$( |
47 |
- "${EPYTHON}" - 3>&1 <<-EOF |
48 |
- import os |
49 |
- import tomli |
50 |
- print(tomli.load(open("pyproject.toml", "rb")) |
51 |
- .get("build-system", {}) |
52 |
- .get("build-backend", ""), |
53 |
- file=os.fdopen(3, "w")) |
54 |
- EOF |
55 |
- ) |
56 |
- fi |
57 |
+ build_backend=$(gpep517 get-backend) |
58 |
fi |
59 |
if [[ -z ${build_backend} && ${DISTUTILS_USE_PEP517} == setuptools && |
60 |
-f setup.py ]] |
61 |
@@ -1107,45 +1084,18 @@ distutils_pep517_install() { |
62 |
|
63 |
local build_backend=$(_distutils-r1_get_backend) |
64 |
einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}" |
65 |
- if [[ ${GPEP517_TESTING} ]]; then |
66 |
- local wheel=$( |
67 |
- gpep517 build-wheel --backend "${build_backend}" \ |
68 |
- --output-fd 3 \ |
69 |
- --wheel-dir "${WHEEL_BUILD_DIR}" 3>&1 >&2 || |
70 |
- die "Wheel build failed" |
71 |
- ) |
72 |
- else |
73 |
- local wheel=$( |
74 |
- "${EPYTHON}" - 3>&1 >&2 <<-EOF || die "Wheel build failed" |
75 |
- import ${build_backend%:*} |
76 |
- import os |
77 |
- print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']), |
78 |
- file=os.fdopen(3, 'w')) |
79 |
- EOF |
80 |
- ) |
81 |
- fi |
82 |
+ local wheel=$( |
83 |
+ gpep517 build-wheel --backend "${build_backend}" \ |
84 |
+ --output-fd 3 \ |
85 |
+ --wheel-dir "${WHEEL_BUILD_DIR}" 3>&1 >&2 || |
86 |
+ die "Wheel build failed" |
87 |
+ ) |
88 |
[[ -n ${wheel} ]] || die "No wheel name returned" |
89 |
|
90 |
einfo " Installing the wheel to ${root}" |
91 |
- if [[ ${GPEP517_TESTING} ]]; then |
92 |
- gpep517 install-wheel --destdir="${root}" --interpreter="${PYTHON}" \ |
93 |
- --prefix="${EPREFIX}/usr" "${WHEEL_BUILD_DIR}/${wheel}" || |
94 |
- die "Wheel install failed" |
95 |
- else |
96 |
- # NB: --compile-bytecode does not produce the correct paths, |
97 |
- # and python_optimize doesn't handle being called outside D, |
98 |
- # so we just defer compiling until the final merge |
99 |
- # NB: we override sys.prefix & sys.exec_prefix because otherwise |
100 |
- # installer would use virtualenv's prefix |
101 |
- local -x PYTHON_PREFIX=${EPREFIX}/usr |
102 |
- "${EPYTHON}" - -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" --no-compile-bytecode \ |
103 |
- <<-EOF || die "installer failed" |
104 |
- import os, sys |
105 |
- sys.prefix = sys.exec_prefix = os.environ["PYTHON_PREFIX"] |
106 |
- from installer.__main__ import main |
107 |
- main(sys.argv[1:]) |
108 |
- EOF |
109 |
- fi |
110 |
+ gpep517 install-wheel --destdir="${root}" --interpreter="${PYTHON}" \ |
111 |
+ --prefix="${EPREFIX}/usr" "${WHEEL_BUILD_DIR}/${wheel}" || |
112 |
+ die "Wheel install failed" |
113 |
|
114 |
# remove installed licenses |
115 |
find "${root}$(python_get_sitedir)" \ |
116 |
@@ -1155,11 +1105,7 @@ distutils_pep517_install() { |
117 |
# clean the build tree; otherwise we may end up with PyPy3 |
118 |
# extensions duplicated into CPython dists |
119 |
if [[ ${DISTUTILS_USE_PEP517:-setuptools} == setuptools ]]; then |
120 |
- if [[ ${GPEP517_TESTING} ]]; then |
121 |
- rm -rf build || die |
122 |
- else |
123 |
- esetup.py clean -a |
124 |
- fi |
125 |
+ rm -rf build || die |
126 |
fi |
127 |
} |
128 |
|
129 |
@@ -1182,13 +1128,13 @@ distutils-r1_python_compile() { |
130 |
# call setup.py build when using setuptools (either via PEP517 |
131 |
# or in legacy mode) |
132 |
|
133 |
- if [[ ${GPEP517_TESTING} && ${DISTUTILS_USE_PEP517} ]]; then |
134 |
+ if [[ ${DISTUTILS_USE_PEP517} ]]; then |
135 |
if [[ -d build ]]; then |
136 |
eqawarn "A 'build' directory exists already. Artifacts from this directory may" |
137 |
eqawarn "be picked up by setuptools when building for another interpreter." |
138 |
eqawarn "Please remove this directory prior to building." |
139 |
fi |
140 |
- elif [[ ! ${DISTUTILS_USE_PEP517} ]]; then |
141 |
+ else |
142 |
_distutils-r1_copy_egg_info |
143 |
fi |
144 |
|
145 |
@@ -1199,7 +1145,7 @@ distutils-r1_python_compile() { |
146 |
jobs=$(( nproc + 1 )) |
147 |
fi |
148 |
|
149 |
- if [[ ${DISTUTILS_USE_PEP517} && ${GPEP517_TESTING} ]]; then |
150 |
+ if [[ ${DISTUTILS_USE_PEP517} ]]; then |
151 |
# issue build_ext only if it looks like we have at least |
152 |
# two source files to build; setuptools is expensive |
153 |
# to start and parallel builds can only benefit us if we're |
154 |
-- |
155 |
2.35.1 |