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 1/3] distutils-r1.eclass: Run build_ext only if there are 2+ files
Date: Fri, 22 Apr 2022 07:51:22
Message-Id: 20220422075032.646637-1-mgorny@gentoo.org
1 Run parallel build_ext only if there are at least two potential source
2 files to compile. This call is expensive and parallel builds do not
3 benefit us if there is only one file to compile.
4
5 Signed-off-by: Michał Górny <mgorny@g.o>
6 ---
7 eclass/distutils-r1.eclass | 12 ++++++++----
8 1 file changed, 8 insertions(+), 4 deletions(-)
9
10 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
11 index 5528ff74cccf..d213cca4bb72 100644
12 --- a/eclass/distutils-r1.eclass
13 +++ b/eclass/distutils-r1.eclass
14 @@ -1189,14 +1189,18 @@ distutils-r1_python_compile() {
15 fi
16
17 if [[ ${DISTUTILS_USE_PEP517} && ${GPEP517_TESTING} ]]; then
18 - # issue build_ext only if it looks like we have something
19 - # to build; setuptools is expensive to start
20 + # issue build_ext only if it looks like we have at least
21 + # two source files to build; setuptools is expensive
22 + # to start and parallel builds can only benefit us if we're
23 + # compiling at least two files
24 + #
25 # see extension.py for list of suffixes
26 # .pyx is added for Cython
27 - if [[ -n $(
28 + if [[ 2 -eq $(
29 find '(' -name '*.c' -o -name '*.cc' -o -name '*.cpp' \
30 -o -name '*.cxx' -o -name '*.c++' -o -name '*.m' \
31 - -o -name '*.mm' -o -name '*.pyx' ')' -print -quit
32 + -o -name '*.mm' -o -name '*.pyx' ')' -printf '\n' |
33 + head -n 2 | wc -l
34 ) ]]; then
35 esetup.py build_ext -j "${jobs}" "${@}"
36 fi
37 --
38 2.35.1

Replies