Skip to content

Commit 3831ae0

Browse files
authored
Merge pull request #217 from messense/cibuildwheel
Fix building macOS arm64 wheel with cibuildwheel
2 parents 179281a + 751a4e1 commit 3831ae0

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fmt:
1414
runs-on: "ubuntu-latest"
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717

1818
- name: Set up Python ${{ matrix.python-version }}
1919
uses: actions/setup-python@v2
@@ -27,7 +27,7 @@ jobs:
2727
mypy:
2828
runs-on: "ubuntu-latest"
2929
steps:
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
3131

3232
- name: Set up Python ${{ matrix.python-version }}
3333
uses: actions/setup-python@v2
@@ -41,7 +41,7 @@ jobs:
4141
pytest:
4242
runs-on: "ubuntu-latest"
4343
steps:
44-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v3
4545

4646
- name: Set up Python ${{ matrix.python-version }}
4747
uses: actions/setup-python@v2
@@ -75,7 +75,7 @@ jobs:
7575
platform: { os: "windows-latest", python-architecture: "x86" }
7676

7777
steps:
78-
- uses: actions/checkout@v2
78+
- uses: actions/checkout@v3
7979

8080
- name: Set up Python ${{ matrix.python-version }}
8181
uses: actions/setup-python@v2
@@ -248,7 +248,7 @@ jobs:
248248
test-cross:
249249
runs-on: ubuntu-latest
250250
steps:
251-
- uses: actions/checkout@master
251+
- uses: actions/checkout@v3
252252
- name: Setup python
253253
uses: actions/setup-python@v2
254254
with:
@@ -293,7 +293,7 @@ jobs:
293293
test-zigbuild:
294294
runs-on: ubuntu-latest
295295
steps:
296-
- uses: actions/checkout@master
296+
- uses: actions/checkout@v3
297297
- name: Setup python
298298
uses: actions/setup-python@v2
299299
with:
@@ -338,3 +338,22 @@ jobs:
338338
pip3 install namespace_package --no-index --find-links /io/dist/ --force-reinstall
339339
python3 -c "from namespace_package import rust; assert rust.rust_func() == 14"
340340
python3 -c "from namespace_package import python; assert python.python_func() == 15"
341+
342+
test-cibuildwheel:
343+
runs-on: macos-latest
344+
steps:
345+
- uses: actions/checkout@v3
346+
- uses: actions-rs/toolchain@v1
347+
with:
348+
profile: minimal
349+
toolchain: stable
350+
target: aarch64-apple-darwin
351+
override: true
352+
- uses: pypa/cibuildwheel@v2.3.1
353+
env:
354+
CIBW_BUILD: cp39-*
355+
CIBW_BEFORE_BUILD: pip install -e .
356+
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
357+
CIBW_BUILD_VERBOSITY: 1
358+
with:
359+
package-dir: examples/namespace_package

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- Add support for `kebab-case` executable names. [#205](https://github.com/PyO3/setuptools-rust/pull/205)
66
- Add support for custom cargo profiles. [#216](https://github.com/PyO3/setuptools-rust/pull/216)
77

8+
### Fixed
9+
- Fix building macOS arm64 wheel with cibuildwheel. [#217](https://github.com/PyO3/setuptools-rust/pull/217)
10+
811
## 1.1.2 (2021-12-05)
912
### Changed
1013
- Removed dependency on `tomli` to simplify installation. [#200](https://github.com/PyO3/setuptools-rust/pull/200)

setuptools_rust/build.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ def run_for_extension(self, ext: RustExtension) -> None:
9292
universal2 = False
9393
if self.plat_name.startswith("macosx-") and arch_flags:
9494
universal2 = "x86_64" in arch_flags and "arm64" in arch_flags
95+
if not universal2 and not self.target:
96+
if "arm64" in arch_flags:
97+
self.target = "aarch64-apple-darwin"
98+
elif "x86_64" in arch_flags:
99+
self.target = "x86_64-apple-darwin"
100+
95101
if universal2:
96102
arm64_dylib_paths = self.build_extension(ext, "aarch64-apple-darwin")
97103
x86_64_dylib_paths = self.build_extension(ext, "x86_64-apple-darwin")

0 commit comments

Comments
 (0)