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
print(f'{c.yellow}Warning{c.end} {message}')
print()
def error(self, error: Union[BaseException, str]) -> None:
print()
@@ -133,6 +135,8 @@ class Logger:
c = self.colors
print(f'{c.bright_red}Error{c.end} {error}')
print()
def _start_fold_group(self, name: str) -> None:
self._end_fold_group()
self.active_fold_group_name = name
+6 -6
View File
@@ -13,7 +13,7 @@ from .environment import ParsedEnvironment
from .logger import log
from .util import (Architecture, BuildOptions, BuildSelector, NonPlatformWheelError,
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
@@ -75,7 +75,7 @@ def get_python_configurations(build_selector: BuildSelector,
if any(c.identifier.startswith('pp') for c in python_configurations):
# pypy doesn't work on macOS 11 yet
# 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,
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.
@@ -84,7 +84,7 @@ def get_python_configurations(build_selector: BuildSelector,
if any(c.identifier.startswith('cp35') for c in python_configurations):
# 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,
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.
@@ -338,14 +338,14 @@ def build(options: BuildOptions) -> None:
if machine_arch == 'x86_64':
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
ability to test the arm64 wheels will be added in a future release of
cibuildwheel, once Apple Silicon CI runners are widely available.
'''))
testing_archs = []
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
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
@@ -363,7 +363,7 @@ def build(options: BuildOptions) -> None:
testing_archs = ['arm64', 'x86_64']
else:
testing_archs = ['arm64']
for testing_arch in testing_archs:
log.step('Testing wheel...' if testing_arch == machine_arch else f'Testing wheel on {testing_arch}...')
+3 -5
View File
@@ -244,15 +244,13 @@ def detect_ci_provider() -> Optional[CIProvider]:
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
text = textwrap.dedent(text)
# remove leading/trailing whitespace
text = text.strip()
# remove consecutive whitespace
text = re.sub(r'\s+', ' ', text)
# wrap to max_width
return '\n'.join(textwrap.wrap(text, width=max_width))
return re.sub(r'\s+', ' ', text)