Skip to content

Commit 466a089

Browse files
authored
Disable buffered output in build scripts (#316)
This fixes the issue where logs printed using `print()` from the build scripts show up at the very end after all the subprocess output. e.g. https://github.com/microsoft/qsharp/actions/runs/4986064660/jobs/8926399062#step:8:1407
1 parent 269a1a0 commit 466a089

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

build.py

+4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
import venv
1111
import shutil
1212
import subprocess
13+
import functools
1314

1415
from prereqs import check_prereqs
1516

17+
# Disable buffered output so that the log statements and subprocess output get interleaved in proper order
18+
print = functools.partial(print, flush=True)
19+
1620
parser = argparse.ArgumentParser(
1721
description="Builds all projects in the repo, unless specific projects to build are passed "
1822
"as options, in which case only those projects are built."

prereqs.py

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import subprocess
1212
import tempfile
13+
import functools
1314

1415
python_ver = (3, 11) # Python support for Windows on ARM64 requires v3.11 or later
1516
rust_ver = (1, 69) # Ensure Rust version 1.69 or later is installed
@@ -21,6 +22,9 @@
2122
rust_fmt_ver = (1, 5, 2) # Current version when Rust 1.69 shipped
2223
clippy_ver = (0, 1, 69)
2324

25+
# Disable buffered output so that the log statements and subprocess output get interleaved in proper order
26+
print = functools.partial(print, flush=True)
27+
2428

2529
def check_prereqs(install=False):
2630
### Check the Python version ###

0 commit comments

Comments
 (0)