1 |
commit: 5eed1a007f6274c7560d980c200469c5732b192b |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Feb 4 21:30:56 2022 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 9 08:43:52 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5eed1a00 |
7 |
|
8 |
distutils-r1.eclass: Use heredoc instead of "python -c" |
9 |
|
10 |
Use heredocs instead of inlining longish scripts in "python -c", |
11 |
for greater readability. Thanks to arthurzam for the suggestion. |
12 |
|
13 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
14 |
|
15 |
eclass/distutils-r1.eclass | 32 ++++++++++++++++++++++---------- |
16 |
1 file changed, 22 insertions(+), 10 deletions(-) |
17 |
|
18 |
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass |
19 |
index b4bbb7d67e04..a1b840d9cc68 100644 |
20 |
--- a/eclass/distutils-r1.eclass |
21 |
+++ b/eclass/distutils-r1.eclass |
22 |
@@ -936,9 +936,13 @@ _distutils-r1_get_backend() { |
23 |
if [[ -f pyproject.toml ]]; then |
24 |
# if pyproject.toml exists, try getting the backend from it |
25 |
# NB: this could fail if pyproject.toml doesn't list one |
26 |
- build_backend=$("${EPYTHON}" -c 'import tomli; \ |
27 |
- print(tomli.load(open("pyproject.toml", "rb")) \ |
28 |
- ["build-system"]["build-backend"])' 2>/dev/null) |
29 |
+ build_backend=$( |
30 |
+ "${EPYTHON}" - <<-EOF 2>/dev/null |
31 |
+ import tomli |
32 |
+ print(tomli.load(open("pyproject.toml", "rb")) |
33 |
+ ["build-system"]["build-backend"]) |
34 |
+ EOF |
35 |
+ ) |
36 |
fi |
37 |
if [[ -z ${build_backend} && ${DISTUTILS_USE_PEP517} == setuptools && |
38 |
-f setup.py ]] |
39 |
@@ -1004,10 +1008,14 @@ distutils_pep517_install() { |
40 |
|
41 |
local build_backend=$(_distutils-r1_get_backend) |
42 |
einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}" |
43 |
- local wheel=$("${EPYTHON}" -c "import ${build_backend%:*}; \ |
44 |
- import os; \ |
45 |
- print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']), |
46 |
- file=os.fdopen(3, 'w'))" 3>&1 >&2 || die "Wheel build failed") |
47 |
+ local wheel=$( |
48 |
+ "${EPYTHON}" - 3>&1 >&2 <<-EOF || die "Wheel build failed" |
49 |
+ import ${build_backend%:*} |
50 |
+ import os |
51 |
+ print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']), |
52 |
+ file=os.fdopen(3, 'w')) |
53 |
+ EOF |
54 |
+ ) |
55 |
[[ -n ${wheel} ]] || die "No wheel name returned" |
56 |
|
57 |
einfo " Installing the wheel to ${root}" |
58 |
@@ -1017,9 +1025,13 @@ distutils_pep517_install() { |
59 |
# NB: we override sys.prefix & sys.exec_prefix because otherwise |
60 |
# installer would use virtualenv's prefix |
61 |
local -x PYTHON_PREFIX=${EPREFIX}/usr |
62 |
- "${EPYTHON}" -c 'import os, sys; sys.prefix = sys.exec_prefix = os.environ["PYTHON_PREFIX"]; from installer.__main__ import main; main(sys.argv[1:])' \ |
63 |
- -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" --no-compile-bytecode || |
64 |
- die "installer failed" |
65 |
+ "${EPYTHON}" - -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" --no-compile-bytecode \ |
66 |
+ <<-EOF || die "installer failed" |
67 |
+ import os, sys |
68 |
+ sys.prefix = sys.exec_prefix = os.environ["PYTHON_PREFIX"] |
69 |
+ from installer.__main__ import main |
70 |
+ main(sys.argv[1:]) |
71 |
+ EOF |
72 |
|
73 |
# remove installed licenses |
74 |
find "${root}$(python_get_sitedir)" \ |