From 61480e2264d2a11c9a0536b1ad6fbe209f79187a Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 6 Aug 2022 11:15:11 +0200 Subject: [PATCH 1/3] fix: don't build `universal2` as a default on macOS arm64 runners --- cibuildwheel/architecture.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cibuildwheel/architecture.py b/cibuildwheel/architecture.py index 82a78b30b..7b90ff947 100644 --- a/cibuildwheel/architecture.py +++ b/cibuildwheel/architecture.py @@ -66,10 +66,6 @@ def auto_archs(platform: PlatformName) -> set[Architecture]: if platform == "windows" and native_architecture == Architecture.AMD64: result.add(Architecture.x86) - if platform == "macos" and native_architecture == Architecture.arm64: - # arm64 can build and test both archs of a universal2 wheel. - result.add(Architecture.universal2) - return result @staticmethod From 03c8f5b741ca25a1ece914117bfe31b2eaa59c6f Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 8 Aug 2022 09:15:36 +0100 Subject: [PATCH 2/3] Docs/examples updates --- docs/faq.md | 11 +++++------ docs/options.md | 2 +- examples/github-apple-silicon.yml | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 07c5397ea..614e7ef6f 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -53,11 +53,11 @@ to load on Apple Silicon. available. Generally speaking, because Pip 20.3 is required for the `universal2` wheel, -most packages should provide both `x86_64` and `universal2` wheels for now. -Once Pip 20.3+ is common on macOS, then it should be possible to ship only the -`universal2` wheel. +most packages should provide both `x86_64` and one of `universal2`/`arm64` +wheels for now. When Pip 20.3+ is common on macOS, then it might be possible +to ship only the `universal2` wheel. -**Apple Silicon wheels are not built by default**, but can be enabled by adding extra archs to the [`CIBW_ARCHS_MACOS` option](options.md#archs) - e.g. `x86_64 arm64 universal2`. Cross-compilation is provided by the Xcode toolchain. +**Apple Silicon wheels are not built by default on Intel runners**, but can be enabled by adding extra archs to the [`CIBW_ARCHS_MACOS` option](options.md#archs) - e.g. `x86_64 arm64`. Cross-compilation is provided by the Xcode toolchain. !!! important When cross-compiling on Intel, it is not possible to test `arm64` and the `arm64` part of a `universal2` wheel. @@ -66,8 +66,7 @@ Once Pip 20.3+ is common on macOS, then it should be possible to ship only the Hopefully, cross-compilation is a temporary situation. Once we have widely available Apple Silicon CI runners, we can build and test `arm64` and -`universal2` wheels natively. That's why `universal2` wheels are not yet built -by default, and require opt-in by setting `CIBW_ARCHS_MACOS`. +`universal2` wheels natively. That's why `universal2`/`arm64` wheels require opt-in by setting `CIBW_ARCHS_MACOS`. !!! note Your runner needs Xcode Command Line Tools 12.2 or later to build `universal2` or `arm64`. diff --git a/docs/options.md b/docs/options.md index 75c2fd806..b6e0b0c5d 100644 --- a/docs/options.md +++ b/docs/options.md @@ -351,7 +351,7 @@ Default: `auto` | Linux / Intel | `x86_64` | `x86_64` `i686` | `x86_64` | `i686` | | Windows / Intel | `AMD64` | `AMD64` `x86` | `AMD64` | `x86` | | macOS / Intel | `x86_64` | `x86_64` | `x86_64` | | -| macOS / AppleĀ Silicon | `arm64` | `arm64` `universal2` | `arm64` `universal2`| | +| macOS / AppleĀ Silicon | `arm64` | `arm64` | `arm64` | | If not listed above, `auto` is the same as `native`. diff --git a/examples/github-apple-silicon.yml b/examples/github-apple-silicon.yml index 95154a33b..d810dfd68 100644 --- a/examples/github-apple-silicon.yml +++ b/examples/github-apple-silicon.yml @@ -12,7 +12,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.8.1 env: - CIBW_ARCHS_MACOS: x86_64 universal2 + CIBW_ARCHS_MACOS: x86_64 arm64 - uses: actions/upload-artifact@v3 with: From ac42f66a7234eaf9949f8c95870f918a532c9ca9 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 8 Aug 2022 18:20:57 +0100 Subject: [PATCH 3/3] Change expected_wheels to only expect universal2 when a flag is passed --- test/test_macos_archs.py | 2 +- test/utils.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/test_macos_archs.py b/test/test_macos_archs.py index d3a56fb7a..fdd665c0e 100644 --- a/test/test_macos_archs.py +++ b/test/test_macos_archs.py @@ -11,7 +11,7 @@ ALL_MACOS_WHEELS = { *utils.expected_wheels("spam", "0.1.0", machine_arch="x86_64"), - *utils.expected_wheels("spam", "0.1.0", machine_arch="arm64"), + *utils.expected_wheels("spam", "0.1.0", machine_arch="arm64", include_universal2=True), } diff --git a/test/utils.py b/test/utils.py index 947c89689..5d6105164 100644 --- a/test/utils.py +++ b/test/utils.py @@ -116,6 +116,7 @@ def expected_wheels( macosx_deployment_target="10.9", machine_arch=None, python_abi_tags=None, + include_universal2=False, ): """ Returns a list of expected wheels from a run of cibuildwheel. @@ -199,14 +200,14 @@ def expected_wheels( arm64_macosx_deployment_target = _get_arm64_macosx_deployment_target( macosx_deployment_target ) - platform_tags = [ - f'macosx_{macosx_deployment_target.replace(".", "_")}_universal2', - f'macosx_{arm64_macosx_deployment_target.replace(".", "_")}_arm64', - ] + platform_tags = [f'macosx_{arm64_macosx_deployment_target.replace(".", "_")}_arm64'] else: - platform_tags = [ - f'macosx_{macosx_deployment_target.replace(".", "_")}_x86_64', - ] + platform_tags = [f'macosx_{macosx_deployment_target.replace(".", "_")}_x86_64'] + + if include_universal2: + platform_tags.append( + f'macosx_{macosx_deployment_target.replace(".", "_")}_universal2', + ) else: raise Exception("unsupported platform")