Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 22/30] python-utils-r1.eclass: Use heredoc instead of "python -c"
Date: Sun, 06 Feb 2022 12:55:52
Message-Id: 20220206124841.1299133-23-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 00/30] One batch of Python eclass updates to rule them all by "Michał Górny"
1 Signed-off-by: Michał Górny <mgorny@g.o>
2 ---
3 eclass/python-utils-r1.eclass | 41 ++++++++++++++++++++++++++++++-----
4 1 file changed, 36 insertions(+), 5 deletions(-)
5
6 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
7 index a42ae66d9c89..d423a28cccb5 100644
8 --- a/eclass/python-utils-r1.eclass
9 +++ b/eclass/python-utils-r1.eclass
10 @@ -316,13 +316,23 @@ _python_export() {
11 ;;
12 PYTHON_SITEDIR)
13 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
14 - PYTHON_SITEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("purelib"))') || die
15 + PYTHON_SITEDIR=$(
16 + "${PYTHON}" - <<-EOF || die
17 + import sysconfig
18 + print(sysconfig.get_path("purelib"))
19 + EOF
20 + )
21 export PYTHON_SITEDIR
22 debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
23 ;;
24 PYTHON_INCLUDEDIR)
25 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
26 - PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("platinclude"))') || die
27 + PYTHON_INCLUDEDIR=$(
28 + "${PYTHON}" - <<-EOF || die
29 + import sysconfig
30 + print(sysconfig.get_path("platinclude"))
31 + EOF
32 + )
33 export PYTHON_INCLUDEDIR
34 debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"
35
36 @@ -333,7 +343,17 @@ _python_export() {
37 ;;
38 PYTHON_LIBPATH)
39 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
40 - PYTHON_LIBPATH=$("${PYTHON}" -c 'import os.path, sysconfig; print(os.path.join(sysconfig.get_config_var("LIBDIR"), sysconfig.get_config_var("LDLIBRARY")) if sysconfig.get_config_var("LDLIBRARY") else "")') || die
41 + PYTHON_LIBPATH=$(
42 + "${PYTHON}" - <<-EOF || die
43 + import os.path, sysconfig
44 + print(
45 + os.path.join(
46 + sysconfig.get_config_var("LIBDIR"),
47 + sysconfig.get_config_var("LDLIBRARY"))
48 + if sysconfig.get_config_var("LDLIBRARY")
49 + else "")
50 + EOF
51 + )
52 export PYTHON_LIBPATH
53 debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}"
54
55 @@ -383,7 +403,13 @@ _python_export() {
56 case "${impl}" in
57 python*)
58 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
59 - flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die
60 + flags=$(
61 + "${PYTHON}" - <<-EOF || die
62 + import sysconfig
63 + print(sysconfig.get_config_var("ABIFLAGS")
64 + or "")
65 + EOF
66 + )
67 val=${PYTHON}${flags}-config
68 ;;
69 *)
70 @@ -574,7 +600,12 @@ python_optimize() {
71 if [[ ${f} == /* && -d ${D%/}${f} ]]; then
72 set -- "${D%/}${f}" "${@}"
73 fi
74 - done < <("${PYTHON}" -c 'import sys; print("".join(x + "\0" for x in sys.path))' || die)
75 + done < <(
76 + "${PYTHON}" - <<-EOF || die
77 + import sys
78 + print("".join(x + "\0" for x in sys.path))
79 + EOF
80 + )
81
82 debug-print "${FUNCNAME}: using sys.path: ${*/%/;}"
83 fi
84 --
85 2.35.1