Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't build universal2 as a default on macOS arm64 runners #1217

Merged
merged 3 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cibuildwheel/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion examples/github-apple-silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_ARCHS_MACOS: x86_64 arm64

- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion test/test_macos_archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}


Expand Down
15 changes: 8 additions & 7 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down