Improve output formatting

Github annotations require all output to be on a single line, so let's
make the log messages do that
This commit is contained in:
Joe Rickerby
2021-01-05 19:02:15 +00:00
parent 0df5e1295f
commit ffba89dc64
3 changed files with 13 additions and 11 deletions
+4
View File
@@ -124,6 +124,8 @@ class Logger:
c = self.colors c = self.colors
print(f'{c.yellow}Warning{c.end} {message}') print(f'{c.yellow}Warning{c.end} {message}')
print()
def error(self, error: Union[BaseException, str]) -> None: def error(self, error: Union[BaseException, str]) -> None:
print() print()
@@ -133,6 +135,8 @@ class Logger:
c = self.colors c = self.colors
print(f'{c.bright_red}Error{c.end} {error}') print(f'{c.bright_red}Error{c.end} {error}')
print()
def _start_fold_group(self, name: str) -> None: def _start_fold_group(self, name: str) -> None:
self._end_fold_group() self._end_fold_group()
self.active_fold_group_name = name self.active_fold_group_name = name
+5 -5
View File
@@ -13,7 +13,7 @@ from .environment import ParsedEnvironment
from .logger import log from .logger import log
from .util import (Architecture, BuildOptions, BuildSelector, NonPlatformWheelError, from .util import (Architecture, BuildOptions, BuildSelector, NonPlatformWheelError,
download, get_build_verbosity_extra_flags, get_pip_script, download, get_build_verbosity_extra_flags, get_pip_script,
install_certifi_script, prepare_command, wrap_text) install_certifi_script, prepare_command, unwrap)
from .typing import PathOrStr from .typing import PathOrStr
@@ -75,7 +75,7 @@ def get_python_configurations(build_selector: BuildSelector,
if any(c.identifier.startswith('pp') for c in python_configurations): if any(c.identifier.startswith('pp') for c in python_configurations):
# pypy doesn't work on macOS 11 yet # pypy doesn't work on macOS 11 yet
# See https://foss.heptapod.net/pypy/pypy/-/issues/3314 # See https://foss.heptapod.net/pypy/pypy/-/issues/3314
log.warning(wrap_text(''' log.warning(unwrap('''
PyPy is currently unsupported when building on macOS 11. To build macOS PyPy wheels, PyPy is currently unsupported when building on macOS 11. To build macOS PyPy wheels,
build on an older OS, such as macOS 10.15. To silence this warning, deselect PyPy by build on an older OS, such as macOS 10.15. To silence this warning, deselect PyPy by
adding "pp*-macosx*" to your CIBW_SKIP option. adding "pp*-macosx*" to your CIBW_SKIP option.
@@ -84,7 +84,7 @@ def get_python_configurations(build_selector: BuildSelector,
if any(c.identifier.startswith('cp35') for c in python_configurations): if any(c.identifier.startswith('cp35') for c in python_configurations):
# CPython 3.5 doesn't work on macOS 11 # CPython 3.5 doesn't work on macOS 11
log.warning(wrap_text(''' log.warning(unwrap('''
CPython 3.5 is unsupported when building on macOS 11. To build CPython 3.5 wheels, CPython 3.5 is unsupported when building on macOS 11. To build CPython 3.5 wheels,
build on an older OS, such as macOS 10.15. To silence this warning, deselect CPython build on an older OS, such as macOS 10.15. To silence this warning, deselect CPython
3.5 by adding "cp35-macosx_x86_64" to your CIBW_SKIP option. 3.5 by adding "cp35-macosx_x86_64" to your CIBW_SKIP option.
@@ -338,14 +338,14 @@ def build(options: BuildOptions) -> None:
if machine_arch == 'x86_64': if machine_arch == 'x86_64':
if config.identifier.endswith('_arm64'): if config.identifier.endswith('_arm64'):
log.warning(wrap_text(''' log.warning(unwrap('''
While arm64 wheels can be built on x86_64, they cannot be tested. The While arm64 wheels can be built on x86_64, they cannot be tested. The
ability to test the arm64 wheels will be added in a future release of ability to test the arm64 wheels will be added in a future release of
cibuildwheel, once Apple Silicon CI runners are widely available. cibuildwheel, once Apple Silicon CI runners are widely available.
''')) '''))
testing_archs = [] testing_archs = []
elif config.identifier.endswith('_universal2'): elif config.identifier.endswith('_universal2'):
log.warning(wrap_text(''' log.warning(unwrap('''
While universal2 wheels can be built on x86_64, the arm64 part of them While universal2 wheels can be built on x86_64, the arm64 part of them
cannot currently be tested. The ability to test the arm64 part of a cannot currently be tested. The ability to test the arm64 part of a
universal2 wheel will be added in a future release of cibuildwheel, once universal2 wheel will be added in a future release of cibuildwheel, once
+3 -5
View File
@@ -244,15 +244,13 @@ def detect_ci_provider() -> Optional[CIProvider]:
return None return None
def wrap_text(text: str, max_width: int = 80) -> str: def unwrap(text: str) -> str:
''' '''
Formats text, suitable for printing arbitrary long passages to console. Unwraps multi-line text to a single line
''' '''
# remove initial line indent # remove initial line indent
text = textwrap.dedent(text) text = textwrap.dedent(text)
# remove leading/trailing whitespace # remove leading/trailing whitespace
text = text.strip() text = text.strip()
# remove consecutive whitespace # remove consecutive whitespace
text = re.sub(r'\s+', ' ', text) return re.sub(r'\s+', ' ', text)
# wrap to max_width
return '\n'.join(textwrap.wrap(text, width=max_width))