• [gentoo-dev] [PATCH 2/2] distutils-r1.eclass: Skip build_ext when there

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Sun Apr 10 00:00:01 2022
    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 <mgorny@gentoo.org>
    ---
    eclass/distutils-r1.eclass | 7 ++++++-
    1 file changed, 6 insertions(+), 1 deletion(-)

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index 1a0097647c41..4d9db7586371 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -1133,7 +1133,12 @@ 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
    + if [[ -n $(find '(' -name '*.c' -o -name '*.pyx' ')' -print -quit) ]]
    + then
    + esetup.py build_ext -j "${jobs}" "${@}"
    + fi
    else
    esetup.py build -j "${jobs}" "${@}"
    fi
    --
    2.35.1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)