feat: Print FatalError messages using Logger (#2292)

* feat: Print FatalError messages using Logger

This makes them appear GHA annotations in CI logs, which makes them easier to spot. I've also added the "cibuildwheel: " prefix to those errors, I think it helps when viewing a log to know which tool is talking to you - it can be difficult to understand with build tools.

* Nicer error message on invalid architecture

* Fix some message formatting and test expectations
This commit is contained in:
Joe Rickerby
2025-03-01 10:47:44 +01:00
committed by GitHub
parent 708cf1d32b
commit 9e72cd9b54
6 changed files with 28 additions and 23 deletions
+4 -5
View File
@@ -68,7 +68,7 @@ def main() -> None:
if log.step_active:
log.step_end_with_error(message)
else:
print(f"cibuildwheel: {message}", file=sys.stderr)
log.error(message)
if global_options.print_traceback_on_error:
traceback.print_exc(file=sys.stderr)
@@ -253,7 +253,7 @@ def _compute_platform_auto() -> PlatformName:
return "windows"
else:
msg = (
'cibuildwheel: Unable to detect platform from "sys.platform". cibuildwheel doesn\'t '
'Unable to detect platform from "sys.platform". cibuildwheel doesn\'t '
"support building wheels for this platform. You might be able to build for a different "
"platform using the --platform argument. Check --help output for more information."
)
@@ -343,9 +343,8 @@ def print_new_wheels(msg: str, output_dir: Path) -> Generator[None, None, None]:
def build_in_directory(args: CommandLineArguments) -> None:
platform: PlatformName = _compute_platform(args)
if platform == "pyodide" and sys.platform == "win32":
msg = "cibuildwheel: Building for pyodide is not supported on Windows"
print(msg, file=sys.stderr)
sys.exit(2)
msg = "Building for pyodide is not supported on Windows"
raise errors.ConfigurationError(msg)
options = compute_options(platform=platform, command_line_arguments=args, env=os.environ)