@@ -163,16 +163,25 @@ def prepare(script=None, outdir=None):
163
163
if not MAKE :
164
164
raise UnsupportedError ('make' )
165
165
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
+
166
175
# Build python.
167
- print (f'building python in { builddir } ...' )
176
+ print (f'building python { parallel = } in { builddir } ...' )
168
177
if os .path .exists (os .path .join (srcdir , 'Makefile' )):
169
178
# Out-of-tree builds require a clean srcdir.
170
179
_run_quiet ([MAKE , '-C' , srcdir , 'clean' ])
171
- _run_quiet ([MAKE , '-C' , builddir , '-j8' ])
180
+ _run_quiet ([MAKE , '-C' , builddir , parallel ])
172
181
173
182
# Install the build.
174
183
print (f'installing python into { prefix } ...' )
175
- _run_quiet ([MAKE , '-C' , builddir , '-j8' , ' install' ])
184
+ _run_quiet ([MAKE , '-C' , builddir , 'install' ])
176
185
python = os .path .join (prefix , 'bin' , 'python3' )
177
186
178
187
return outdir , scriptfile , python
0 commit comments