@@ -27,8 +27,10 @@ class UnsupportedError(Exception):
2727 """The operation isn't supported."""
2828
2929
30- def _run_quiet (cmd , cwd = None ):
31- #print(f'# {" ".join(shlex.quote(a) for a in cmd)}')
30+ def _run_quiet (cmd , * , cwd = None ):
31+ if cwd :
32+ print ('+' , 'cd' , cwd , flush = True )
33+ print ('+' , shlex .join (cmd ), flush = True )
3234 try :
3335 return subprocess .run (
3436 cmd ,
@@ -48,8 +50,8 @@ def _run_quiet(cmd, cwd=None):
4850 raise
4951
5052
51- def _run_stdout (cmd , cwd = None ):
52- proc = _run_quiet (cmd , cwd )
53+ def _run_stdout (cmd ):
54+ proc = _run_quiet (cmd )
5355 return proc .stdout .strip ()
5456
5557
@@ -91,13 +93,16 @@ def copy_source_tree(newroot, oldroot):
9193
9294 shutil .copytree (oldroot , newroot , ignore = support .copy_python_src_ignore )
9395 if os .path .exists (os .path .join (newroot , 'Makefile' )):
94- _run_quiet ([MAKE , 'clean' ], newroot )
96+ _run_quiet ([MAKE , 'clean' ], cwd = newroot )
9597
9698
9799##################################
98100# freezing
99101
100102def prepare (script = None , outdir = None ):
103+ print ()
104+ print ("cwd:" , os .getcwd ())
105+
101106 if not outdir :
102107 outdir = OUTDIR
103108 os .makedirs (outdir , exist_ok = True )
@@ -125,7 +130,7 @@ def prepare(script=None, outdir=None):
125130 ensure_opt (cmd , 'cache-file' , os .path .join (outdir , 'python-config.cache' ))
126131 prefix = os .path .join (outdir , 'python-installation' )
127132 ensure_opt (cmd , 'prefix' , prefix )
128- _run_quiet (cmd , builddir )
133+ _run_quiet (cmd , cwd = builddir )
129134
130135 if not MAKE :
131136 raise UnsupportedError ('make' )
@@ -135,20 +140,21 @@ def prepare(script=None, outdir=None):
135140 # this test is most often run as part of the whole suite with a lot
136141 # of other tests running in parallel, from 1-2 vCPU systems up to
137142 # people's NNN core beasts. Don't attempt to use it all.
138- parallel = f'-j{ cores * 2 // 3 } '
143+ jobs = cores * 2 // 3
144+ parallel = f'-j{ jobs } '
139145 else :
140146 parallel = '-j2'
141147
142148 # Build python.
143149 print (f'building python { parallel = } in { builddir } ...' )
144150 if os .path .exists (os .path .join (srcdir , 'Makefile' )):
145151 # Out-of-tree builds require a clean srcdir.
146- _run_quiet ([MAKE , '-C' , srcdir , 'clean' ] )
147- _run_quiet ([MAKE , '-C' , builddir , parallel ] )
152+ _run_quiet ([MAKE , 'clean' ], cwd = srcdir )
153+ _run_quiet ([MAKE , parallel ], cwd = builddir )
148154
149155 # Install the build.
150156 print (f'installing python into { prefix } ...' )
151- _run_quiet ([MAKE , '-C' , builddir , 'install' ] )
157+ _run_quiet ([MAKE , 'install' ], cwd = builddir )
152158 python = os .path .join (prefix , 'bin' , 'python3' )
153159
154160 return outdir , scriptfile , python
@@ -161,8 +167,8 @@ def freeze(python, scriptfile, outdir):
161167 print (f'freezing { scriptfile } ...' )
162168 os .makedirs (outdir , exist_ok = True )
163169 # Use -E to ignore PYTHONSAFEPATH
164- _run_quiet ([python , '-E' , FREEZE , '-o' , outdir , scriptfile ], outdir )
165- _run_quiet ([MAKE , '-C' , os .path .dirname (scriptfile )] )
170+ _run_quiet ([python , '-E' , FREEZE , '-o' , outdir , scriptfile ], cwd = outdir )
171+ _run_quiet ([MAKE ], cwd = os .path .dirname (scriptfile ))
166172
167173 name = os .path .basename (scriptfile ).rpartition ('.' )[0 ]
168174 executable = os .path .join (outdir , name )
0 commit comments