Skip to content

Commit 81b0a57

Browse files
mayeuthenryiiijoerickradarhere
authored
chore(CI): test on GHA macOS-14 runner (#1700)
* chore(CI): test on GHA macOS-14 runner * update error message for skipped arm64 tests * Update docs, README and examples --------- Co-authored-by: Henry Schreiner <[email protected]> Co-authored-by: Joe Rickerby <[email protected]> Co-authored-by: Andrew Murray <[email protected]>
1 parent 27d0942 commit 81b0a57

12 files changed

+46
-85
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
runs-on: ${{ matrix.os }}
3939
strategy:
4040
matrix:
41-
os: [ubuntu-20.04, windows-latest, macos-11]
41+
os: [ubuntu-20.04, windows-latest, macos-13, macos-14]
4242
python_version: ['3.12']
4343
include:
4444
- os: ubuntu-22.04

README.md

+12-17
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,17 @@ What does it do?
2727
| CPython 3.6 || N/A ||| N/A ||||||
2828
| CPython 3.7 || N/A ||| N/A ||||||
2929
| CPython 3.8 ||||| N/A ||||||
30-
| CPython 3.9 ||||| ✅² |³ |||||
30+
| CPython 3.9 ||||| ✅² ||||||
3131
| CPython 3.10 ||||| ✅² ||||||
3232
| CPython 3.11 ||||| ✅² ||||||
33-
| CPython 3.12 ||||| ✅² ||||||
33+
| CPython 3.12 ||||| ✅² ||||||
3434
| PyPy 3.7 v7.3 || N/A || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A |
35-
| PyPy 3.8 v7.3 || || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A |
36-
| PyPy 3.9 v7.3 || || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A |
37-
| PyPy 3.10 v7.3 || || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A |
35+
| PyPy 3.8 v7.3 || || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A |
36+
| PyPy 3.9 v7.3 || || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A |
37+
| PyPy 3.10 v7.3 || || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A |
3838

3939
<sup>¹ PyPy is only supported for manylinux wheels.</sup><br>
4040
<sup>² Windows arm64 support is experimental.</sup><br>
41-
<sup>³ Alpine 3.14 and very briefly 3.15's default python3 [was not able to load](https://github.com/pypa/cibuildwheel/issues/934) musllinux wheels. This has been fixed; please upgrade the python package if using Alpine from before the fix.</sup><br>
42-
<sup>⁴ Cross-compilation not supported with PyPy - to build these wheels you need to run cibuildwheel on an Apple Silicon machine.</sup><br>
43-
<sup>⁵ CPython 3.12 is built by default using Python RCs, starting with cibuildwheel 2.15.</sup><br>
4441

4542
- Builds manylinux, musllinux, macOS 10.9+, and Windows wheels for CPython and PyPy
4643
- Works on GitHub Actions, Azure Pipelines, Travis CI, AppVeyor, CircleCI, GitLab CI, and Cirrus CI
@@ -56,18 +53,16 @@ Usage
5653

5754
| | Linux | macOS | Windows | Linux ARM | macOS ARM | Windows ARM |
5855
|-----------------|-------|-------|---------|-----------|-----------|-------------|
59-
| GitHub Actions |||| ✅¹ |² | |
60-
| Azure Pipelines |||| |² | |
56+
| GitHub Actions ||| | ✅¹ | |² |
57+
| Azure Pipelines ||| | | |² |
6158
| Travis CI || ||| | |
62-
| AppVeyor |||| |² | |
63-
| CircleCI ||| ||² | |
59+
| AppVeyor |||| | |² |
60+
| CircleCI ||| || | |
6461
| Gitlab CI || || ✅¹ | | |
65-
| Cirrus CI ||³ |||| |
62+
| Cirrus CI || |||| |
6663

6764
<sup[Requires emulation](https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation), distributed separately. Other services may also support Linux ARM through emulation or third-party build hosts, but these are not tested in our CI.</sup><br>
68-
<sup[Uses cross-compilation](https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2). It is not possible to test `arm64` and the `arm64` part of a `universal2` wheel on this CI platform.</sup><br>
69-
<sup[Uses cross-compilation](https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2). Thanks to Rosetta 2 emulation, it is possible to test `x86_64` and both parts of a `universal2` wheel on this CI platform.</sup><br>
70-
<sup>⁴ [Uses cross-compilation](https://cibuildwheel.readthedocs.io/en/stable/faq/#windows-arm64). It is not possible to test `arm64` on this CI platform.</sup>
65+
<sup[Uses cross-compilation](https://cibuildwheel.readthedocs.io/en/stable/faq/#windows-arm64). It is not possible to test `arm64` on this CI platform.</sup>
7166

7267
<!--intro-end-->
7368

@@ -87,7 +82,7 @@ jobs:
8782
runs-on: ${{ matrix.os }}
8883
strategy:
8984
matrix:
90-
os: [ubuntu-20.04, windows-2019, macOS-11]
85+
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
9186

9287
steps:
9388
- uses: actions/checkout@v4

cibuildwheel/macos.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,8 @@ def build(options: Options, tmp_path: Path) -> None:
488488
unwrap(
489489
"""
490490
While arm64 wheels can be built on x86_64, they cannot be
491-
tested. The ability to test the arm64 wheels will be added in a
492-
future release of cibuildwheel, once Apple Silicon CI runners
493-
are widely available. To silence this warning, set
491+
tested. Consider building arm64 wheels natively, if your CI
492+
provider offers this. To silence this warning, set
494493
`CIBW_TEST_SKIP: "*-macosx_arm64"`.
495494
"""
496495
)
@@ -500,11 +499,11 @@ def build(options: Options, tmp_path: Path) -> None:
500499
unwrap(
501500
"""
502501
While universal2 wheels can be built on x86_64, the arm64 part
503-
of them cannot currently be tested. The ability to test the
504-
arm64 part of a universal2 wheel will be added in a future
505-
release of cibuildwheel, once Apple Silicon CI runners are
506-
widely available. To silence this warning, set
507-
`CIBW_TEST_SKIP: "*-macosx_universal2:arm64"`.
502+
of the wheel cannot be tested on x86_64. Consider building
503+
universal2 wheels on an arm64 runner, if your CI provider offers
504+
this. Notably, an arm64 runner can also test the x86_64 part of
505+
the wheel, through Rosetta emulation. To silence this warning,
506+
set `CIBW_TEST_SKIP: "*-macosx_universal2:arm64"`.
508507
"""
509508
)
510509
)

docs/extra.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ h1, h2, h3, h4, h5, h6 {
255255
border: none;
256256
color: inherit;
257257
background-color: #f0f1f1;
258-
font-size: 100%;
258+
font-size: 80%;
259259
}
260260

261261

docs/faq.md

+11-28
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ Linux wheels are built in [`manylinux`/`musllinux` containers](https://github.co
2020

2121
### Building macOS wheels for Apple Silicon {: #apple-silicon}
2222

23-
`cibuildwheel` supports cross-compiling `universal2` and `arm64` wheels on `x86_64` runners.
23+
`cibuildwheel` supports both native builds and cross-compiling between `arm64` (Apple Silicon) and `x86_64` (Intel) architectures, including the cross-compatible `universal2` format.
2424

2525
#### Overview of Mac architectures
2626

27-
With the introduction of Apple Silicon, you now have several choices for wheels for Python 3.8+:
27+
You have several choices for wheels for Python 3.8+:
2828

2929
##### `x86_64`
3030

@@ -68,43 +68,26 @@ Opinions vary on which of arch-specific or `universal2` wheels are best - some p
6868

6969
See [GitHub issue 1333](https://github.com/pypa/cibuildwheel/issues/1333) for more discussion.
7070

71-
#### How to cross-compile
71+
#### How?
7272

73-
With the exception of Cirrus CI, macOS CI runners are still Intel-based, and Apple Silicon wheels are not built by default on Intel runners. However, cross-compilation 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.
73+
It's easiest to build `x86_64` wheels on `x86_64` runners, and `arm64` wheels on `arm64` runners.
7474

75-
!!! important
76-
When cross-compiling on Intel, it is not possible to test `arm64` and the `arm64` part of a `universal2` wheel.
75+
On GitHub Actions, `macos-14` runners are `arm64`, and `macos-13` runners are `x86_64`. So all you need to do is ensure both are in your build matrix.
7776

78-
`cibuildwheel` will raise a warning to notify you of this - these warnings be be silenced by skipping testing on these platforms: `CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64"`.
77+
#### Cross-compiling
7978

80-
!!! note
81-
Your runner needs Xcode Command Line Tools 12.2 or later to build `universal2` or `arm64`.
79+
If your CI provider doesn't offer arm64 runners yet, or you want to create `universal2`, you'll have to cross-compile. Cross-compilation can be enabled by adding extra archs to the [`CIBW_ARCHS_MACOS` option](options.md#archs) - e.g. `CIBW_ARCHS_MACOS="x86_64 universal2"`. Cross-compilation is provided by Xcode toolchain v12.2+.
80+
81+
Regarding testing,
8282

83-
Only CPython 3.8 and newer support `universal2` and `arm64` wheels.
83+
- On an arm64 runner, it is possible to test x86_64 wheels and both parts of a universal2 wheel using Rosetta 2 emulation.
84+
- On an x86_64 runner, arm64 code can be compiled but it can't be tested. `cibuildwheel` will raise a warning to notify you of this - these warnings can be silenced by skipping testing on these platforms: `CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64"`.
8485

8586
!!! note
8687
If your project uses **Poetry** as a build backend, cross-compiling on macOS [does not currently work](https://github.com/python-poetry/poetry/issues/7107). In some cases arm64 wheels can be built but their tags will be incorrect, with the platform tag showing `x86_64` instead of `arm64`.
8788

8889
As a workaround, the tag can be fixed before running delocate to repair the wheel. The [`wheel tags`](https://wheel.readthedocs.io/en/stable/reference/wheel_tags.html) command is ideal for this. See [this workflow](https://gist.github.com/anderssonjohan/49f07e33fc5cb2420515a8ac76dc0c95#file-build-pendulum-wheels-yml-L39-L53) for an example usage of `wheel tags`.
8990

90-
Hopefully, cross-compilation is a temporary situation. Once we have widely available Apple Silicon CI runners, we can build `arm64` wheels natively. Until then, cross-compiling `arm64` or `universal2` wheels requires opt-in by setting `CIBW_ARCHS_MACOS` on Intel runners.
91-
92-
Here's an example GitHub Actions workflow with a job that builds for Apple Silicon:
93-
94-
> .github/workflows/build_macos.yml
95-
96-
```yml
97-
{% include "../examples/github-apple-silicon.yml" %}
98-
```
99-
100-
Here's an example Cirrus CI workflow with a job that builds for macOS Intel through Rosetta 2 emulation and for Apple Silicon natively:
101-
102-
> .cirrus.yml
103-
104-
```yml
105-
{% include "../examples/cirrus-ci-intel-mac.yml" %}
106-
```
107-
10891
### Building Linux wheels for non-native archs using emulation {: #emulation}
10992

11093
cibuildwheel supports building non-native architectures on Linux, via

docs/options.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ See the [cibuildwheel 1 documentation](https://cibuildwheel.readthedocs.io/en/1.
343343
344344
A list of architectures to build.
345345

346-
On macOS, this option can be used to cross-compile between `x86_64`,
347-
`universal2` and `arm64` for Apple Silicon support.
346+
On macOS, this option can be used to [cross-compile](faq.md#cross-compiling)
347+
between `x86_64`, `universal2` and `arm64`.
348348

349349
On Linux, this option can be used to build non-native architectures under
350350
emulation. See [this guide](faq.md#emulation) for more information.

docs/setup.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/
178178
runs-on: ${{ matrix.os }}
179179
strategy:
180180
matrix:
181-
os: [ubuntu-20.04, windows-2019, macos-11]
181+
# macos-13 is an intel runner, macos-14 is apple silicon
182+
os: [ubuntu-20.04, windows-2019, macos-13, macos-14]
182183

183184
steps:
184185
- uses: actions/checkout@v4
@@ -211,7 +212,8 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/
211212
runs-on: ${{ matrix.os }}
212213
strategy:
213214
matrix:
214-
os: [ubuntu-20.04, windows-2019, macos-11]
215+
# macos-13 is an intel runner, macos-14 is apple silicon
216+
os: [ubuntu-20.04, windows-2019, macos-13, macos-14]
215217

216218
steps:
217219
- uses: actions/checkout@v4

examples/github-apple-silicon.yml

-20
This file was deleted.

examples/github-deploy.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
matrix:
19-
os: [ubuntu-22.04, windows-2022, macos-11]
19+
# macos-13 is an intel runner, macos-14 is apple silicon
20+
os: [ubuntu-22.04, windows-2022, macos-13, macos-14]
2021

2122
steps:
2223
- uses: actions/checkout@v4

examples/github-minimal.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
os: [ubuntu-20.04, windows-2019, macos-11]
11+
# macos-13 is an intel runner, macos-14 is apple silicon
12+
os: [ubuntu-20.04, windows-2019, macos-13, macos-14]
1213

1314
steps:
1415
- uses: actions/checkout@v4

examples/github-with-qemu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
os: [ubuntu-20.04, windows-2019, macos-11]
11+
os: [ubuntu-20.04, windows-2019, macos-13, macos-14]
1212

1313
steps:
1414
- uses: actions/checkout@v4

test/test_macos_archs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_cross_compiled_test(tmp_path, capfd, build_universal2):
8383
assert "running tests on arm64" not in captured.out
8484
if build_universal2:
8585
assert (
86-
"While universal2 wheels can be built on x86_64, the arm64 part of them cannot currently be tested"
86+
"While universal2 wheels can be built on x86_64, the arm64 part of the wheel cannot be tested"
8787
in captured.err
8888
)
8989
else:
@@ -95,7 +95,7 @@ def test_cross_compiled_test(tmp_path, capfd, build_universal2):
9595
assert "running tests on x86_64" in captured.out
9696
assert "running tests on arm64" in captured.out
9797
assert (
98-
"While universal2 wheels can be built on x86_64, the arm64 part of them cannot currently be tested"
98+
"While universal2 wheels can be built on x86_64, the arm64 part of the wheel cannot be tested"
9999
not in captured.err
100100
)
101101
assert (
@@ -162,7 +162,7 @@ def test_universal2_testing_on_x86_64(tmp_path, capfd, skip_arm64_test):
162162
assert "running tests on x86_64" in captured.out
163163
assert "running tests on arm64" not in captured.out
164164

165-
warning_message = "While universal2 wheels can be built on x86_64, the arm64 part of them cannot currently be tested"
165+
warning_message = "While universal2 wheels can be built on x86_64, the arm64 part of the wheel cannot be tested"
166166
if skip_arm64_test:
167167
assert warning_message not in captured.err
168168
else:

0 commit comments

Comments
 (0)