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 2/2] distutils-r1.eclass: Skip build_ext when there no .c/.pyx files
Date: Sat, 09 Apr 2022 21:58:47
Message-Id: 20220409215820.241220-2-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/2] distutils-r1.eclass: Call build_ext instead of build in PEP517 mode by "Michał Górny"
1 Skip issuing build_ext when there appears to be no .c/.pyx files.
2 Since starting setuptools is expensive, this gives a major speedup
3 to building pure Python packages. If the check misfires, the worst
4 that can happen is that C extensions will be built serialized.
5
6 Signed-off-by: Michał Górny <mgorny@g.o>
7 ---
8 eclass/distutils-r1.eclass | 7 ++++++-
9 1 file changed, 6 insertions(+), 1 deletion(-)
10
11 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
12 index 1a0097647c41..4d9db7586371 100644
13 --- a/eclass/distutils-r1.eclass
14 +++ b/eclass/distutils-r1.eclass
15 @@ -1133,7 +1133,12 @@ distutils-r1_python_compile() {
16 fi
17
18 if [[ ${DISTUTILS_USE_PEP517} && ${GPEP517_TESTING} ]]; then
19 - esetup.py build_ext -j "${jobs}" "${@}"
20 + # issue build_ext only if it looks like we have something
21 + # to build; setuptools is expensive to start
22 + if [[ -n $(find '(' -name '*.c' -o -name '*.pyx' ')' -print -quit) ]]
23 + then
24 + esetup.py build_ext -j "${jobs}" "${@}"
25 + fi
26 else
27 esetup.py build -j "${jobs}" "${@}"
28 fi
29 --
30 2.35.1