diff --git a/repos/spack_repo/builtin/build_systems/python.py b/repos/spack_repo/builtin/build_systems/python.py index f4ca6c190fe..9945ca0df5b 100644 --- a/repos/spack_repo/builtin/build_systems/python.py +++ b/repos/spack_repo/builtin/build_systems/python.py @@ -19,10 +19,12 @@ build_system, classproperty, depends_on, + determine_number_of_jobs, execute_install_time_tests, extends, filter_file, find, + get_effective_jobs, has_shebang, join_path, path_contains_subdirectory, @@ -313,7 +315,7 @@ def build_directory(self) -> str: """ return self.pkg.stage.source_path - def config_settings(self, spec: Spec, prefix: Prefix) -> Mapping[str, object]: + def config_settings(self, spec: Spec, prefix: Prefix) -> Dict[str, object]: """Configuration settings to be passed to the PEP 517 build backend. Requires pip 22.1 or newer for keys that appear only a single time, @@ -363,8 +365,18 @@ def install(self, pkg: PythonPackage, spec: Spec, prefix: Prefix) -> None: pip.add_default_arg("-m", "pip") args = PythonPipBuilder.std_args(pkg) + [f"--prefix={prefix}"] - - for setting in _flatten_dict(self.config_settings(spec, prefix)): + config_settings = self.config_settings(spec, prefix) + + # Pass -jN for compile-args if supported and needed + if spec.satisfies("%py-pip@22.1: %py-meson-python@0.11:"): + # get_effective_jobs returns None when a jobserver is active, then we don't pass -j. + jobs = get_effective_jobs( + jobs=determine_number_of_jobs(parallel=pkg.parallel), supports_jobserver=True + ) + if jobs is not None: + config_settings["compile-args"] = f"-j{jobs}" + + for setting in _flatten_dict(config_settings): args.append(f"--config-settings={setting}") for option in self.install_options(spec, prefix): args.append(f"--install-option={option}") diff --git a/repos/spack_repo/builtin/packages/py_matplotlib/package.py b/repos/spack_repo/builtin/packages/py_matplotlib/package.py index 2b327125cf5..99ade6cb6b1 100644 --- a/repos/spack_repo/builtin/packages/py_matplotlib/package.py +++ b/repos/spack_repo/builtin/packages/py_matplotlib/package.py @@ -300,7 +300,6 @@ def flag_handler(self, name, flags): def config_settings(self, spec, prefix): return { "builddir": "build", - "compile-args": f"-j{make_jobs}", "setup-args": { "-Dsystem-freetype": True, "-Dsystem-qhull": True, diff --git a/repos/spack_repo/builtin/packages/py_numpy/package.py b/repos/spack_repo/builtin/packages/py_numpy/package.py index 453341f2ddc..b923de9286a 100644 --- a/repos/spack_repo/builtin/packages/py_numpy/package.py +++ b/repos/spack_repo/builtin/packages/py_numpy/package.py @@ -337,7 +337,6 @@ def config_settings(self, spec, prefix): settings = { "builddir": "build", - "compile-args": f"-j{make_jobs}", "setup-args": { # https://scipy.github.io/devdocs/building/blas_lapack.html "-Dblas": blas, diff --git a/repos/spack_repo/builtin/packages/py_scikit_learn/package.py b/repos/spack_repo/builtin/packages/py_scikit_learn/package.py index 12a117b5449..3e8db6b1ad6 100644 --- a/repos/spack_repo/builtin/packages/py_scikit_learn/package.py +++ b/repos/spack_repo/builtin/packages/py_scikit_learn/package.py @@ -119,8 +119,9 @@ def url_for_version(self, version): return url.format(name, version) def setup_build_environment(self, env: EnvironmentModifications) -> None: - # Enable parallel builds of the sklearn backend - env.append_flags("SKLEARN_BUILD_PARALLEL", str(make_jobs)) + if self.spec.satisfies("@:1.4"): + # Enable parallel builds for the pre py-meson-python build system + env.append_flags("SKLEARN_BUILD_PARALLEL", str(make_jobs)) # https://scikit-learn.org/stable/developers/advanced_installation.html#macos if self.spec.satisfies("%apple-clang"): diff --git a/repos/spack_repo/builtin/packages/py_scipy/package.py b/repos/spack_repo/builtin/packages/py_scipy/package.py index 28be6e3418a..00f697484a4 100644 --- a/repos/spack_repo/builtin/packages/py_scipy/package.py +++ b/repos/spack_repo/builtin/packages/py_scipy/package.py @@ -227,7 +227,6 @@ def config_settings(self, spec, prefix): return { "builddir": "build", - "compile-args": f"-j{make_jobs}", "setup-args": { # http://scipy.github.io/devdocs/building/blas_lapack.html "-Dfortran_std": fortran_std,