@@ -27,8 +27,10 @@ class UnsupportedError(Exception):
27
27
"""The operation isn't supported."""
28
28
29
29
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 )
32
34
try :
33
35
return subprocess .run (
34
36
cmd ,
@@ -48,8 +50,8 @@ def _run_quiet(cmd, cwd=None):
48
50
raise
49
51
50
52
51
- def _run_stdout (cmd , cwd = None ):
52
- proc = _run_quiet (cmd , cwd )
53
+ def _run_stdout (cmd ):
54
+ proc = _run_quiet (cmd )
53
55
return proc .stdout .strip ()
54
56
55
57
@@ -91,13 +93,16 @@ def copy_source_tree(newroot, oldroot):
91
93
92
94
shutil .copytree (oldroot , newroot , ignore = support .copy_python_src_ignore )
93
95
if os .path .exists (os .path .join (newroot , 'Makefile' )):
94
- _run_quiet ([MAKE , 'clean' ], newroot )
96
+ _run_quiet ([MAKE , 'clean' ], cwd = newroot )
95
97
96
98
97
99
##################################
98
100
# freezing
99
101
100
102
def prepare (script = None , outdir = None ):
103
+ print ()
104
+ print ("cwd:" , os .getcwd ())
105
+
101
106
if not outdir :
102
107
outdir = OUTDIR
103
108
os .makedirs (outdir , exist_ok = True )
@@ -125,7 +130,7 @@ def prepare(script=None, outdir=None):
125
130
ensure_opt (cmd , 'cache-file' , os .path .join (outdir , 'python-config.cache' ))
126
131
prefix = os .path .join (outdir , 'python-installation' )
127
132
ensure_opt (cmd , 'prefix' , prefix )
128
- _run_quiet (cmd , builddir )
133
+ _run_quiet (cmd , cwd = builddir )
129
134
130
135
if not MAKE :
131
136
raise UnsupportedError ('make' )
@@ -135,20 +140,21 @@ def prepare(script=None, outdir=None):
135
140
# this test is most often run as part of the whole suite with a lot
136
141
# of other tests running in parallel, from 1-2 vCPU systems up to
137
142
# 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 } '
139
145
else :
140
146
parallel = '-j2'
141
147
142
148
# Build python.
143
149
print (f'building python { parallel = } in { builddir } ...' )
144
150
if os .path .exists (os .path .join (srcdir , 'Makefile' )):
145
151
# 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 )
148
154
149
155
# Install the build.
150
156
print (f'installing python into { prefix } ...' )
151
- _run_quiet ([MAKE , '-C' , builddir , 'install' ] )
157
+ _run_quiet ([MAKE , 'install' ], cwd = builddir )
152
158
python = os .path .join (prefix , 'bin' , 'python3' )
153
159
154
160
return outdir , scriptfile , python
@@ -161,8 +167,8 @@ def freeze(python, scriptfile, outdir):
161
167
print (f'freezing { scriptfile } ...' )
162
168
os .makedirs (outdir , exist_ok = True )
163
169
# 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 ))
166
172
167
173
name = os .path .basename (scriptfile ).rpartition ('.' )[0 ]
168
174
executable = os .path .join (outdir , name )
0 commit comments