1 |
Python 3.5+ introduces parallel build support in distutils. Take |
2 |
advantage of that by passing appropriate -j option. Since distutils |
3 |
does not support an equivalent of --load-average, default to the number |
4 |
of CPUs+1 when unspecified. |
5 |
|
6 |
In order to avoid breaking stable systems, introduce the new behavior |
7 |
only for EAPI 7 ebuilds, or older EAPI ebuilds with unstable |
8 |
implementations (Python 3.7 and PyPy 3). |
9 |
--- |
10 |
eclass/distutils-r1.eclass | 22 +++++++++++++++++++--- |
11 |
1 file changed, 19 insertions(+), 3 deletions(-) |
12 |
|
13 |
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass |
14 |
index 975383acc09b..85f8f4cb3be9 100644 |
15 |
--- a/eclass/distutils-r1.eclass |
16 |
+++ b/eclass/distutils-r1.eclass |
17 |
@@ -80,10 +80,10 @@ if [[ ! ${_DISTUTILS_R1} ]]; then |
18 |
|
19 |
[[ ${EAPI} == [45] ]] && inherit eutils |
20 |
[[ ${EAPI} == [56] ]] && inherit xdg-utils |
21 |
-inherit toolchain-funcs |
22 |
+inherit multiprocessing toolchain-funcs |
23 |
|
24 |
if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then |
25 |
- inherit multiprocessing python-r1 |
26 |
+ inherit python-r1 |
27 |
else |
28 |
inherit python-single-r1 |
29 |
fi |
30 |
@@ -454,7 +454,23 @@ distutils-r1_python_compile() { |
31 |
|
32 |
_distutils-r1_copy_egg_info |
33 |
|
34 |
- esetup.py build "${@}" |
35 |
+ local build_args=() |
36 |
+ # distutils is parallel-capable since py3.5 |
37 |
+ # to avoid breaking stable ebuilds, enable it only if either: |
38 |
+ # a. we're dealing with EAPI 7 |
39 |
+ # b. we're dealing with Python 3.7 or PyPy3 |
40 |
+ if python_is_python3 && [[ ${EPYTHON} != python3.4 ]]; then |
41 |
+ if [[ ${EAPI} != [56] || ${EPYTHON} != python3.[56] ]]; then |
42 |
+ local jobs=$(makeopts_jobs "${MAKEOPTS}" INF) |
43 |
+ if [[ ${jobs} == INF ]]; then |
44 |
+ local nproc=$(get_nproc) |
45 |
+ jobs=$(( nproc + 1 )) |
46 |
+ fi |
47 |
+ build_args+=( -j "${jobs}" ) |
48 |
+ fi |
49 |
+ fi |
50 |
+ |
51 |
+ esetup.py build "${build_args[@]}" "${@}" |
52 |
} |
53 |
|
54 |
# @FUNCTION: _distutils-r1_wrap_scripts |
55 |
-- |
56 |
2.18.0 |