Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: eclass/
Date: Thu, 21 Oct 2021 06:39:37
Message-Id: 1634798344.ce4687a8c9a175ac2b08b42881efead4218a7f58.grobian@gentoo
1 commit: ce4687a8c9a175ac2b08b42881efead4218a7f58
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 21 06:39:04 2021 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 21 06:39:04 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=ce4687a8
7
8 python-utils-r1: sync with gx86, bug #818043
9
10 Bug: https://bugs.gentoo.org/818043
11 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
12
13 eclass/python-utils-r1.eclass | 117 ++++++++++++++++++++++--------------------
14 1 file changed, 62 insertions(+), 55 deletions(-)
15
16 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
17 index 0c173e2308..5e035f86a9 100644
18 --- a/eclass/python-utils-r1.eclass
19 +++ b/eclass/python-utils-r1.eclass
20 @@ -35,7 +35,7 @@ fi
21 if [[ ! ${_PYTHON_UTILS_R1} ]]; then
22
23 [[ ${EAPI} == [67] ]] && inherit eapi8-dosym
24 -inherit toolchain-funcs
25 +inherit multiprocessing toolchain-funcs
26
27 # @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
28 # @INTERNAL
29 @@ -353,16 +353,13 @@ _python_export() {
30 ;;
31 PYTHON_SITEDIR)
32 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
33 - # sysconfig can't be used because:
34 - # 1) pypy doesn't give site-packages but stdlib
35 - # 2) jython gives paths with wrong case
36 - PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die
37 + PYTHON_SITEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("purelib"))') || die
38 export PYTHON_SITEDIR
39 debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
40 ;;
41 PYTHON_INCLUDEDIR)
42 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
43 - PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die
44 + PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("platinclude"))') || die
45 export PYTHON_INCLUDEDIR
46 debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"
47
48 @@ -580,46 +577,6 @@ python_get_scriptdir() {
49 echo "${PYTHON_SCRIPTDIR}"
50 }
51
52 -# @FUNCTION: _python_ln_rel
53 -# @USAGE: <from> <to>
54 -# @INTERNAL
55 -# @DESCRIPTION:
56 -# Create a relative symlink.
57 -_python_ln_rel() {
58 - debug-print-function ${FUNCNAME} "${@}"
59 -
60 - local target=${1}
61 - local symname=${2}
62 -
63 - local tgpath=${target%/*}/
64 - local sympath=${symname%/*}/
65 - local rel_target=
66 -
67 - while [[ ${sympath} ]]; do
68 - local tgseg= symseg=
69 -
70 - while [[ ! ${tgseg} && ${tgpath} ]]; do
71 - tgseg=${tgpath%%/*}
72 - tgpath=${tgpath#${tgseg}/}
73 - done
74 -
75 - while [[ ! ${symseg} && ${sympath} ]]; do
76 - symseg=${sympath%%/*}
77 - sympath=${sympath#${symseg}/}
78 - done
79 -
80 - if [[ ${tgseg} != ${symseg} ]]; then
81 - rel_target=../${rel_target}${tgseg:+${tgseg}/}
82 - fi
83 - done
84 - rel_target+=${tgpath}${target##*/}
85 -
86 - debug-print "${FUNCNAME}: ${symname} -> ${target}"
87 - debug-print "${FUNCNAME}: rel_target = ${rel_target}"
88 -
89 - ln -fs "${rel_target}" "${symname}"
90 -}
91 -
92 # @FUNCTION: python_optimize
93 # @USAGE: [<directory>...]
94 # @DESCRIPTION:
95 @@ -661,6 +618,9 @@ python_optimize() {
96 debug-print "${FUNCNAME}: using sys.path: ${*/%/;}"
97 fi
98
99 + local jobs=$(makeopts_jobs "${MAKEOPTS}" INF)
100 + [[ ${jobs} == INF ]] && jobs=$(get_nproc)
101 +
102 local d
103 for d; do
104 # make sure to get a nice path without //
105 @@ -672,11 +632,14 @@ python_optimize() {
106 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
107 "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
108 ;;
109 - python*|pypy3)
110 + python3.[5678]|pypy3)
111 # both levels of optimization are separate since 3.5
112 - "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
113 - "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}"
114 - "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
115 + "${PYTHON}" -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}"
116 + "${PYTHON}" -O -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}"
117 + "${PYTHON}" -OO -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}"
118 + ;;
119 + python*)
120 + "${PYTHON}" -m compileall -j "${jobs}" -o 0 -o 1 -o 2 --hardlink-dupes -q -f -d "${instpath}" "${d}"
121 ;;
122 *)
123 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
124 @@ -1316,17 +1279,46 @@ build_sphinx() {
125 HTML_DOCS+=( "${dir}/_build/html/." )
126 }
127
128 +# @FUNCTION: _python_check_EPYTHON
129 +# @INTERNAL
130 +# @DESCRIPTION:
131 +# Check if EPYTHON is set, die if not.
132 +_python_check_EPYTHON() {
133 + if [[ -z ${EPYTHON} ]]; then
134 + die "EPYTHON unset, invalid call context"
135 + fi
136 +}
137 +
138 +# @VARIABLE: EPYTEST_DESELECT
139 +# @DEFAULT_UNSET
140 +# @DESCRIPTION:
141 +# Specifies an array of tests to be deselected via pytest's --deselect
142 +# parameter, when calling epytest. The list can include file paths,
143 +# specific test functions or parametrized test invocations.
144 +#
145 +# Note that the listed files will still be subject to collection,
146 +# i.e. modules imported in global scope will need to be available.
147 +# If this is undesirable, EPYTEST_IGNORE can be used instead.
148 +
149 +# @VARIABLE: EPYTEST_IGNORE
150 +# @DEFAULT_UNSET
151 +# @DESCRIPTION:
152 +# Specifies an array of paths to be ignored via pytest's --ignore
153 +# parameter, when calling epytest. The listed files will be entirely
154 +# skipped from test collection.
155 +
156 # @FUNCTION: epytest
157 # @USAGE: [<args>...]
158 # @DESCRIPTION:
159 -# Run pytest, passing the standard set of pytest options, followed
160 -# by user-specified options.
161 +# Run pytest, passing the standard set of pytest options, then
162 +# --deselect and --ignore options based on EPYTEST_DESELECT
163 +# and EPYTEST_IGNORE, then user-specified options.
164 #
165 # This command dies on failure and respects nonfatal.
166 epytest() {
167 debug-print-function ${FUNCNAME} "${@}"
168
169 - [[ -n ${EPYTHON} ]] || die "EPYTHON unset, invalid call context"
170 + _python_check_EPYTHON
171
172 local args=(
173 # verbose progress reporting and tracebacks
174 @@ -1336,12 +1328,27 @@ epytest() {
175 -ra
176 # print local variables in tracebacks, useful for debugging
177 -l
178 + # override filterwarnings=error, we do not really want -Werror
179 + # for end users, as it tends to fail on new warnings from deps
180 + -Wdefault
181 )
182 + local x
183 + for x in "${EPYTEST_DESELECT[@]}"; do
184 + args+=( --deselect "${x}" )
185 + done
186 + for x in "${EPYTEST_IGNORE[@]}"; do
187 + args+=( --ignore "${x}" )
188 + done
189 set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}"
190
191 echo "${@}" >&2
192 "${@}" || die -n "pytest failed with ${EPYTHON}"
193 - return ${?}
194 + local ret=${?}
195 +
196 + # remove common temporary directories left over by pytest plugins
197 + rm -rf .hypothesis .pytest_cache || die
198 +
199 + return ${ret}
200 }
201
202 # @FUNCTION: eunittest
203 @@ -1354,7 +1361,7 @@ epytest() {
204 eunittest() {
205 debug-print-function ${FUNCNAME} "${@}"
206
207 - [[ -n ${EPYTHON} ]] || die "EPYTHON unset, invalid call context"
208 + _python_check_EPYTHON
209
210 set -- "${EPYTHON}" -m unittest_or_fail discover -v "${@}"