diff --git a/cibuildwheel/logger.py b/cibuildwheel/logger.py index 4724b605..a6c693f3 100644 --- a/cibuildwheel/logger.py +++ b/cibuildwheel/logger.py @@ -113,6 +113,18 @@ class Logger: def step_end_with_error(self, error: Union[BaseException, str]) -> None: self.step_end(success=False) + self.error(error) + + def warning(self, message: str) -> None: + print() + + if self.fold_mode == 'github': + print(f'::warning::{message}') + else: + c = self.colors + print(f'{c.yellow}Warning{c.end} {message}') + + def error(self, error: Union[BaseException, str]) -> None: print() if self.fold_mode == 'github': diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index d43d2954..0dd5ebac 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -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) + install_certifi_script, prepare_command, wrap_text) from .typing import PathOrStr @@ -64,16 +64,32 @@ def get_python_configurations(build_selector: BuildSelector) -> List[PythonConfi PythonConfiguration(version='3.7', identifier='pp37-macosx_x86_64', url='https://downloads.python.org/pypy/pypy3.7-v7.3.3-osx64.tar.bz2'), ] + # skip builds as required + python_configurations = [c for c in python_configurations if build_selector(c.identifier)] + if get_macos_version() >= (11, 0): # pypy doesn't work on macOS 11 yet # See https://foss.heptapod.net/pypy/pypy/-/issues/3314 - python_configurations = [c for c in python_configurations if not c.identifier.startswith('pp')] + if any(c.identifier.startswith('pp') for c in python_configurations): + log.warning(wrap_text(''' + 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. + ''')) + python_configurations = [c for c in python_configurations if not c.identifier.startswith('pp')] + + if any(c.identifier.startswith('cp35') for c in python_configurations): + # CPython 3.5 doesn't work on macOS 11 + log.warning(wrap_text(''' + CPython 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. + ''')) + python_configurations = [c for c in python_configurations if not c.identifier.startswith('cp35')] - # CPython 3.5 doesn't work on macOS 11 python_configurations = [c for c in python_configurations if not c.identifier.startswith('cp35')] - # skip builds as required - return [c for c in python_configurations if build_selector(c.identifier)] + return python_configurations SYMLINKS_DIR = Path('/tmp/cibw_bin') diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 960b9896..3b4935ff 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -229,3 +229,17 @@ def detect_ci_provider() -> Optional[CIProvider]: return CIProvider.other else: return None + + +def wrap_text(text: str, max_width: int = 80) -> str: + ''' + Formats text, suitable for printing arbitrary long passages to console. + ''' + # 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))