From fa0374ee61e28fda103bac18ec46dbdc37652b09 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sat, 3 Oct 2020 22:56:02 +0200 Subject: [PATCH] Better build system output when stdout is not a tty When piping the output of `setup.py` to another program, that program cannot usually deal with escape sequences well. To fix this, output the compilation progress on new lines instead of overwriting the current line. --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cc8a92f0f..bc756c648 100755 --- a/setup.py +++ b/setup.py @@ -485,8 +485,10 @@ def parallel_run(items: List[Command]) -> None: num += 1 if verbose: print(' '.join(compile_cmd.cmd)) - else: + elif sys.stdout.isatty(): print('\r\x1b[K[{}/{}] {}'.format(num, total, compile_cmd.desc), end='') + else: + print('[{}/{}] {}'.format(num, total, compile_cmd.desc), flush=True) printed = True w = subprocess.Popen(compile_cmd.cmd, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) workers[w.pid] = compile_cmd, w