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.
This commit is contained in:
Luflosi
2020-10-03 22:56:02 +02:00
parent 5b1e1aee3d
commit fa0374ee61

View File

@@ -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