From 4b65ad8d5020d7910edc1c19d4755ab1935ccc73 Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 2 Mar 2022 11:45:17 +0800 Subject: [PATCH 1/2] Add aarch64-apple-darwin test to CI --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e19b07c49e1..0131ff8a336 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -244,6 +244,13 @@ jobs: manylinux: auto args: --release -i python3.9 --no-sdist -m examples/maturin-starter/Cargo.toml + - name: Test cross compilation + if: ${{ matrix.platform.os == 'macos-latest' && matrix.python-version == '3.9' }} + uses: messense/maturin-action@v1 + with: + target: aarch64-apple-darwin + args: --release -i python3.9 --no-sdist -m examples/maturin-starter/Cargo.toml + env: CARGO_TERM_VERBOSE: true CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }} From afe5221724cd48a96eb3a33005ecc48cc066f427 Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 4 Mar 2022 16:37:12 +0800 Subject: [PATCH 2/2] Fix cross compiling to aarch64 macOS --- CHANGELOG.md | 1 + pyo3-build-config/src/impl_.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a03bc340b9..48e81dae805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix incorrect platform detection for Windows in `pyo3-build-config`. [#2198](https://github.com/PyO3/pyo3/pull/2198) +- Fix cross compiling to aarch64 macOS. [#2201](https://github.com/PyO3/pyo3/pull/2201) ## [0.16.0] - 2022-02-27 diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index debbdff533c..25b6db174bd 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -623,7 +623,16 @@ pub fn cross_compiling( let cross_lib_dir = env_var("PYO3_CROSS_LIB_DIR"); let cross_python_version = env_var("PYO3_CROSS_PYTHON_VERSION"); - let target_triple = format!("{}-{}-{}", target_arch, target_vendor, target_os); + let target_triple = format!( + "{}-{}-{}", + target_arch, + target_vendor, + if target_os == "macos" { + "darwin" + } else { + target_os + } + ); if cross.is_none() && cross_lib_dir.is_none() && cross_python_version.is_none() { // No cross-compiling environment variables set; try to determine if this is a known case