@@ -220,7 +220,7 @@ def run(cmd, cwd=None) -> subprocess.CompletedProcess:
220220 """Like subprocess.run, with logging before and after the command execution."""
221221 cmd = [str (arg ) for arg in cmd ]
222222 cmdstring = shlex .join (cmd )
223- logging .debug ("Run: %r " , cmdstring )
223+ logging .debug ("Run: '%s' " , cmdstring )
224224 result = subprocess .run (
225225 cmd ,
226226 cwd = cwd ,
@@ -242,6 +242,21 @@ def run(cmd, cwd=None) -> subprocess.CompletedProcess:
242242 return result
243243
244244
245+ def run_with_logging (cmd , cwd = None ):
246+ """Like subprocess.check_call, with logging before the command execution."""
247+ cmd = list (map (str , cmd ))
248+ logging .debug ("Run: %s" , shlex .join (cmd ))
249+ with subprocess .Popen (cmd , cwd = cwd , encoding = "utf-8" ) as p :
250+ try :
251+ for line in p .stdout :
252+ logging .debug (">>>> %s" , line .rstrip ())
253+ except :
254+ p .kill ()
255+ raise
256+ if return_code := p .poll ():
257+ raise subprocess .CalledProcessError (return_code , cmd [0 ])
258+
259+
245260def changed_files (left , right ):
246261 """Compute a list of different files between left and right, recursively.
247262 Resulting paths are relative to left.
@@ -728,7 +743,7 @@ def is_mac():
728743 self .versions ,
729744 self .checkout / "Doc" / "tools" / "templates" / "indexsidebar.html" ,
730745 )
731- run (
746+ run_with_logging (
732747 [
733748 "make" ,
734749 "-C" ,
0 commit comments