-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cross-compilation for MacOS 12 arm64.
- Loading branch information
Showing
5 changed files
with
1,025 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,9 @@ jobs: | |
- os: macos-11 | ||
arch: x86_64 | ||
fflags: -march=x86-64 -mavx | ||
# - os: macos-11 | ||
# arch: arm64 | ||
# fflags: -march=armv8.5-a | ||
- os: macos-12 | ||
arch: arm64 | ||
fflags: -march=armv8.5-a | ||
python: | ||
- version: "3.8" | ||
cp: cp38 | ||
|
@@ -79,11 +79,12 @@ jobs: | |
run: gfortran --version | ||
|
||
- name: Build wheels | ||
if: ${{ matrix.platform.arch != 'arm64' }} | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_BUILD: ${{ matrix.python.cp }}-* | ||
CIBW_BUILD_VERBOSITY: 3 | ||
CIBW_ENVIRONMENT: NPY_DISTUTILS_APPEND_FLAGS=1 FFLAGS='${{ matrix.platform.fflags }}' | ||
CIBW_ENVIRONMENT: FFLAGS='${{ matrix.platform.fflags }}' | ||
CIBW_SKIP: "*-musllinux_*" | ||
CIBW_ARCHS: ${{ matrix.platform.arch }} | ||
CIBW_BEFORE_TEST_LINUX: | | ||
|
@@ -94,6 +95,62 @@ jobs: | |
CIBW_TEST_COMMAND: pytest {package}/tests | ||
PYTHONFAULTHANDLER: "1" | ||
|
||
- name: Build macosx_arm64 | ||
# This is solely used to build macosx_arm64. As soon as Github Actions make | ||
# MacOS arm64 runners available, it should be removed. Adapted from scipy's CI. | ||
if: ${{ matrix.platform.os == 'macos-12' && matrix.platform.arch == 'arm64' }} | ||
run: | | ||
set -ex | ||
# Update license | ||
cat tools/wheels/LICENSE_osx.txt >> LICENSE.txt | ||
export PLAT="arm64" | ||
export _PYTHON_HOST_PLATFORM="macosx-12.0-arm64" | ||
export CROSS_COMPILE=1 | ||
# Need macOS >= 11 for arm compilation. | ||
export MACOSX_DEPLOYMENT_TARGET=11.0 | ||
# SDK root needs to be set early, installation of gfortran/openblas | ||
# needs to go in the correct location. | ||
export SDKROOT=/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk | ||
export ARCHFLAGS=" -arch arm64 " | ||
source tools/wheels/gfortran_utils.sh | ||
export MACOSX_DEPLOYMENT_TARGET=11.0 | ||
# The install script requires the PLAT variable in order to set | ||
# the FC variable | ||
export PLAT=arm64 | ||
install_arm64_cross_gfortran | ||
export FC=$FC_ARM64 | ||
export PATH=$FC_LOC:$PATH | ||
export FFLAGS=" -arch arm64 $FFLAGS" | ||
export LDFLAGS=" $FC_ARM64_LDFLAGS $LDFLAGS -L/opt/arm64-builds/lib -arch arm64" | ||
sudo ln -s $FC $FC_LOC/gfortran | ||
echo $(type -p gfortran) | ||
# having a test fortran program has helped in debugging problems with the | ||
# compiler environment. | ||
$FC $FFLAGS tools/wheels/test.f $LDFLAGS | ||
ls -al *.out | ||
otool -L a.out | ||
export PKG_CONFIG_PATH=/opt/arm64-builds/lib/pkgconfig | ||
export PKG_CONFIG=/usr/local/bin/pkg-config | ||
export CFLAGS=" -arch arm64 $CFLAGS" | ||
export CXXFLAGS=" -arch arm64 $CXXFLAGS" | ||
export LD_LIBRARY_PATH="/opt/arm64-builds/lib:$FC_LIBDIR:$LD_LIBRARY_PATH" | ||
# install dependencies for the build machine | ||
pipx run build --wheel | ||
# Enables delocate to find the libopenblas/libgfortran libraries. | ||
export DYLD_LIBRARY_PATH=/opt/gfortran-darwin-arm64/lib/gcc/arm64-apple-darwin20.0.0/10.2.1:/opt/arm64-builds/lib | ||
pip3 install delocate | ||
delocate-listdeps dist/pysimulators*.whl | ||
delocate-wheel --require-archs=arm64 -k -w wheelhouse dist/pysimulators*.whl | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
path: ./wheelhouse/*.whl | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.