Skip to content

Commit

Permalink
distutils-r1.eclass: Skip build_ext when there no .c/.pyx files
Browse files Browse the repository at this point in the history
Skip issuing build_ext when there appears to be no .c/.pyx files.
Since starting setuptools is expensive, this gives a major speedup
to building pure Python packages.  If the check misfires, the worst
that can happen is that C extensions will be built serialized.

Signed-off-by: Michał Górny <[email protected]>
  • Loading branch information
mgorny committed Apr 11, 2022
1 parent ac1735e commit 4986eb8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion eclass/distutils-r1.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,17 @@ distutils-r1_python_compile() {
fi

if [[ ${DISTUTILS_USE_PEP517} && ${GPEP517_TESTING} ]]; then
esetup.py build_ext -j "${jobs}" "${@}"
# issue build_ext only if it looks like we have something
# to build; setuptools is expensive to start
# see extension.py for list of suffixes
# .pyx is added for Cython
if [[ -n $(
find '(' -name '*.c' -o -name '*.cc' -o -name '*.cpp' \
-o -name '*.cxx' -o -name '*.c++' -o -name '*.m' \
-o -name '*.mm' -o -name '*.pyx' ')' -print -quit
) ]]; then
esetup.py build_ext -j "${jobs}" "${@}"
fi
else
esetup.py build -j "${jobs}" "${@}"
fi
Expand Down

0 comments on commit 4986eb8

Please sign in to comment.