Drop use of Unbuffered wrapper class (#2894)
This commit is contained in:
@@ -4,6 +4,7 @@ import argparse
|
|||||||
import contextlib
|
import contextlib
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import functools
|
import functools
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
@@ -30,7 +31,7 @@ from cibuildwheel.util.resources import read_all_configs
|
|||||||
TYPE_CHECKING = False
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from collections.abc import Generator, Iterable, Sequence
|
from collections.abc import Generator, Iterable, Sequence
|
||||||
from typing import Any, Literal, TextIO
|
from typing import Literal
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
@@ -44,23 +45,6 @@ class FileReport:
|
|||||||
size: str
|
size: str
|
||||||
|
|
||||||
|
|
||||||
# Taken from https://stackoverflow.com/a/107717
|
|
||||||
class Unbuffered:
|
|
||||||
def __init__(self, stream: TextIO) -> None:
|
|
||||||
self.stream = stream
|
|
||||||
|
|
||||||
def write(self, data: str) -> None:
|
|
||||||
self.stream.write(data)
|
|
||||||
self.stream.flush()
|
|
||||||
|
|
||||||
def writelines(self, data: Iterable[str]) -> None:
|
|
||||||
self.stream.writelines(data)
|
|
||||||
self.stream.flush()
|
|
||||||
|
|
||||||
def __getattr__(self, attr: str) -> Any: # noqa: ANN401
|
|
||||||
return getattr(self.stream, attr)
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
global_options = GlobalOptions()
|
global_options = GlobalOptions()
|
||||||
try:
|
try:
|
||||||
@@ -360,10 +344,11 @@ def build_in_directory(args: CommandLineArguments) -> None:
|
|||||||
# Add CIBUILDWHEEL environment variable
|
# Add CIBUILDWHEEL environment variable
|
||||||
os.environ["CIBUILDWHEEL"] = "1"
|
os.environ["CIBUILDWHEEL"] = "1"
|
||||||
|
|
||||||
# Python is buffering by default when running on the CI platforms, giving
|
# Python block-buffers stdout when it isn't a tty, which de-interleaves
|
||||||
# problems interleaving subprocess call output with unflushed calls to
|
# `print` output and direct fd-1 writes from subprocesses sharing this
|
||||||
# 'print'
|
# stdout. line_buffering allows each newline to flush all the way to fd-1.
|
||||||
sys.stdout = Unbuffered(sys.stdout)
|
if isinstance(sys.stdout, io.TextIOWrapper):
|
||||||
|
sys.stdout.reconfigure(line_buffering=True)
|
||||||
|
|
||||||
# create the cache dir before it gets printed & builds performed
|
# create the cache dir before it gets printed & builds performed
|
||||||
CIBW_CACHE_PATH.mkdir(parents=True, exist_ok=True)
|
CIBW_CACHE_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user