@@ -163,16 +163,25 @@ def prepare(script=None, outdir=None):
163163 if not MAKE :
164164 raise UnsupportedError ('make' )
165165
166+ cores = os .cpu_count ()
167+ if cores and cores >= 3 :
168+ # this test is most often run as part of the whole suite with a lot
169+ # of other tests running in parallel, from 1-2 vCPU systems up to
170+ # people's NNN core beasts. Don't attempt to use it all.
171+ parallel = f'-j{ cores * 2 // 3 } '
172+ else :
173+ parallel = '-j2'
174+
166175 # Build python.
167- print (f'building python in { builddir } ...' )
176+ print (f'building python { parallel = } in { builddir } ...' )
168177 if os .path .exists (os .path .join (srcdir , 'Makefile' )):
169178 # Out-of-tree builds require a clean srcdir.
170179 _run_quiet ([MAKE , '-C' , srcdir , 'clean' ])
171- _run_quiet ([MAKE , '-C' , builddir , '-j8' ])
180+ _run_quiet ([MAKE , '-C' , builddir , parallel ])
172181
173182 # Install the build.
174183 print (f'installing python into { prefix } ...' )
175- _run_quiet ([MAKE , '-C' , builddir , '-j8' , ' install' ])
184+ _run_quiet ([MAKE , '-C' , builddir , 'install' ])
176185 python = os .path .join (prefix , 'bin' , 'python3' )
177186
178187 return outdir , scriptfile , python
0 commit comments