From e28379e98b11be967343f02f4a1ae3964508b9dc Mon Sep 17 00:00:00 2001 From: AMD Toolchain Support <73240730+amd-toolchain-support@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:24:59 +0530 Subject: [PATCH] python: limit parallellism in compileall (#48441) --- var/spack/repos/builtin/packages/python/package.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py index 2a51a7f5928..dc820db7f7b 100644 --- a/var/spack/repos/builtin/packages/python/package.py +++ b/var/spack/repos/builtin/packages/python/package.py @@ -488,6 +488,11 @@ def patch(self): r"^(.*)setup\.py(.*)((build)|(install))(.*)$", r"\1setup.py\2 --no-user-cfg \3\6" ) + # limit the number of processes to use for compileall in older Python versions + # https://github.com/python/cpython/commit/9a7e9f9921804f3f90151ca42703e612697dd430 + if self.spec.satisfies("@:3.11"): + ff.filter("-j0 ", f"-j{make_jobs} ") + # disable building the nis module (there is no flag to disable it). if self.spec.satisfies("@3.8:3.10"): filter_file( @@ -789,7 +794,7 @@ def install(self, spec, prefix): self.win_installer(prefix) else: # See https://github.com/python/cpython/issues/102007 - make(*self.install_targets, parallel=False) + make(*self.install_targets, f"COMPILEALL_OPTS=-j{make_jobs}", parallel=False) @run_after("install") def filter_compilers(self):