diff --git a/build_docs.py b/build_docs.py index 0805139..3f18a62 100755 --- a/build_docs.py +++ b/build_docs.py @@ -220,7 +220,7 @@ def run(cmd, cwd=None) -> subprocess.CompletedProcess: """Like subprocess.run, with logging before and after the command execution.""" cmd = [str(arg) for arg in cmd] cmdstring = shlex.join(cmd) - logging.debug("Run: %r", cmdstring) + logging.debug("Run: '%s'", cmdstring) result = subprocess.run( cmd, cwd=cwd, @@ -242,6 +242,21 @@ def run(cmd, cwd=None) -> subprocess.CompletedProcess: return result +def run_with_logging(cmd, cwd=None): + """Like subprocess.check_call, with logging before the command execution.""" + cmd = list(map(str, cmd)) + logging.debug("Run: %s", shlex.join(cmd)) + with subprocess.Popen(cmd, cwd=cwd, encoding="utf-8") as p: + try: + for line in p.stdout: + logging.debug(">>>> %s", line.rstrip()) + except: + p.kill() + raise + if return_code := p.poll(): + raise subprocess.CalledProcessError(return_code, cmd[0]) + + def changed_files(left, right): """Compute a list of different files between left and right, recursively. Resulting paths are relative to left. @@ -728,7 +743,7 @@ def is_mac(): self.versions, self.checkout / "Doc" / "tools" / "templates" / "indexsidebar.html", ) - run( + run_with_logging( [ "make", "-C",