nixpkgs/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh
Sergei Trofimovich 187ac583a0
python/hooks/setuptools-build-hook.sh: use --parallel flag only for fresh setuptools
Without the change attempt to enable parallelist for `python2` packages
fails with unsupported `--parallel` flag for `setuptools`-based
packages:

    $ nix build --no-link -f. --arg config '{enableParallelBuildingByDefault = true;}' xdg-utils
    error: builder for '/nix/store/...-python2.7-setuptools-44.0.0.drv' failed with exit code 1;
       last 10 log lines:
       > no configure script, doing nothing
       > Running phase: buildPhase
       > Executing setuptoolsBuildPhase
       > usage: nix_run_setup [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       >    or: nix_run_setup --help [cmd1 cmd2 ...]
       >    or: nix_run_setup --help-commands
       >    or: nix_run_setup cmd --help
       >
       > error: option --parallel not recognized
2024-03-25 13:18:45 +01:00

32 lines
913 B
Bash

# Setup hook for setuptools.
echo "Sourcing setuptools-build-hook"
setuptoolsBuildPhase() {
echo "Executing setuptoolsBuildPhase"
local args setuptools_has_parallel=@setuptools_has_parallel@
runHook preBuild
cp -f @setuppy@ nix_run_setup
args=""
if [ -n "$setupPyGlobalFlags" ]; then
args+="$setupPyGlobalFlags"
fi
if [ -n "$enableParallelBuilding" ]; then
if [ -n "$setuptools_has_parallel" ]; then
setupPyBuildFlags+=" --parallel $NIX_BUILD_CORES"
fi
fi
if [ -n "$setupPyBuildFlags" ]; then
args+=" build_ext $setupPyBuildFlags"
fi
eval "@pythonInterpreter@ nix_run_setup $args bdist_wheel"
runHook postBuild
echo "Finished executing setuptoolsBuildPhase"
}
if [ -z "${dontUseSetuptoolsBuild-}" ] && [ -z "${buildPhase-}" ]; then
echo "Using setuptoolsBuildPhase"
buildPhase=setuptoolsBuildPhase
fi