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

Enable native MacOS Apple Silicon runners #199

Merged
merged 12 commits into from
Mar 23, 2024
6 changes: 4 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ jobs:
run: |
echo "CI_ONLY" $CI_ONLY
if [ "$CI_ONLY" == "true" ]; then
MATRIX="[{'only':'cp312-manylinux_x86_64','os':'ubuntu-20.04'},{'only':'cp312-win_amd64','os':'windows-2019'}, {'only':'cp312-macosx_x86_64','os':'macos-11'}, {'only':'cp312-macosx_arm64','os':'macos-11'}]"
MATRIX="[{'only':'cp312-manylinux_x86_64','os':'ubuntu-20.04'},{'only':'cp312-win_amd64','os':'windows-2019'}, {'only':'cp312-macosx_x86_64','os':'macos-11'}, {'only':'cp312-macosx_arm64','os':'macos-14'}]"
else
MATRIX=$(
{
cibuildwheel --print-build-identifiers --platform linux \
| jq -nRc '{"only": inputs, "os": "ubuntu-20.04"}' \
&& cibuildwheel --print-build-identifiers --platform macos \
&& cibuildwheel --print-build-identifiers --platform macos --archs x86_64 \
| jq -nRc '{"only": inputs, "os": "macos-11"}' \
&& cibuildwheel --print-build-identifiers --platform macos --archs arm64 \
| jq -nRc '{"only": inputs, "os": "macos-14"}' \
&& cibuildwheel --print-build-identifiers --platform windows \
| jq -nRc '{"only": inputs, "os": "windows-2019"}'
} | jq -sc
Expand Down
24 changes: 16 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test-command = "pytest -v {package}/tests"

# Skip trying to test arm64 builds on Intel Macs as per
# https://cibuildwheel.readthedocs.io/en/stable/faq/#apple-silicon
test-skip = "*-macosx_arm64 *-macosx_universal2:arm64"
# test-skip = "*-macosx_arm64 *-macosx_universal2:arm64"
# don't try and install pypi packages and build from source
environment = { PIP_ONLY_BINARY=":all:" }

Expand Down Expand Up @@ -50,20 +50,28 @@ before-all = "apk add swig gsl-dev"
[tool.cibuildwheel.macos]
# do a per-build 'gsl' installation to force correct architecture when
# cross-compiling (https://stackoverflow.com/a/75488269)
before-build = [
"echo ARCHFLAGS = $ARCHFLAGS", # gets the arch at build-time
"if [[ $ARCHFLAGS == *arm64 ]]; then brew fetch --force --bottle-tag=arm64_big_sur gsl; brew reinstall $(brew --cache --bottle-tag=arm64_big_sur gsl); else brew reinstall gsl; fi"
]
before-all = "brew install swig gsl"
# before-build = [
# "echo ARCHFLAGS = $ARCHFLAGS", # gets the arch at build-time
# "if [[ $ARCHFLAGS == *arm64 ]]; then brew fetch --force --bottle-tag=arm64_big_sur gsl; brew reinstall $(brew --cache --bottle-tag=arm64_big_sur gsl); else brew reinstall gsl; fi"
# ]
# note that SWIG is already present on runners, no 'brew' installation neeeded

# support cross-compilation on Apple Silicon
archs = ["arm64", "x86_64"] # don't enable "universal2" binary

[[tool.cibuildwheel.overrides]]
select = "*-macosx_*"
inherit.environment="append"
environment = { CPATH="/opt/homebrew/include", LIBRARY_PATH="/opt/homebrew/lib" }

[tool.cibuildwheel.windows]
# use nuget to install gsl on Windows, and manually supply paths
before-all = "nuget install gsl-msvc14-x64 -Version 2.3.0.2779"
# note that we have to repeat the global PIP_ONLY_BINARY config, because this variables overwrites previous defines
environment = { CPATH="gsl-msvc14-x64.2.3.0.2779\\\\build\\\\native", LIBRARY_PATH="gsl-msvc14-x64.2.3.0.2779\\\\build\\\\native\\\\static", PIP_ONLY_BINARY=":all:" }

[[tool.cibuildwheel.overrides]]
select ="*-win_*"
inherit.environment="append"
environment = { CPATH="gsl-msvc14-x64.2.3.0.2779\\\\build\\\\native", LIBRARY_PATH="gsl-msvc14-x64.2.3.0.2779\\\\build\\\\native\\\\static" }

[build-system]
build-backend = "setuptools.build_meta:__legacy__"
Expand Down
Loading