Skip to content

Commit

Permalink
Try fix for macOS amd64 wheels first
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed May 16, 2024
1 parent 4809a31 commit 2affb9d
Showing 1 changed file with 41 additions and 14 deletions.
55 changes: 41 additions & 14 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,6 @@ jobs:
- name: Clone pybind11 repo (no history)
run: git clone --depth 1 --branch v2.11.1 https://github.com/pybind/pybind11.git

- uses: fortran-lang/setup-fortran@v1.6
id: setup-fortran
with:
compiler: gcc
version: 12

- name: Install SuiteSparse and SUNDIALS on macOS
if: matrix.os == 'macos-12'
run: |
python -m pip install cmake wget
python scripts/install_KLU_Sundials.py
- name: Build wheels on Linux
run: pipx run cibuildwheel --output-dir wheelhouse
if: matrix.os == 'ubuntu-latest'
Expand All @@ -141,8 +129,47 @@ jobs:
run: pipx run cibuildwheel --output-dir wheelhouse
env:
MACOSX_DEPLOYMENT_TARGET: 11.1
CIBW_BEFORE_BUILD_MACOS: >
# Sourced from
# https://github.com/scipy/scipy/blob/f2d4775e7762fad984f8f0acd8227c725ff21630/tools/wheels/cibw_before_build_macos.sh#L23-L49
CIBW_BEFORE_BUILD_MACOS: |
python -m pip install --upgrade cmake casadi setuptools wheel
# download gfortran with proper macos minimum version (11.0)
curl -L https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-x86_64-native.tar.gz -o gfortran.tar.gz
GFORTRAN_SHA256=$(shasum --algorithm 256 gfortran.tar.gz)
KNOWN_SHA256="981367dd0ad4335613e91bbee453d60b6669f5d7e976d18c7bdb7f1966f26ae4 gfortran.tar.gz"
if [ "$GFORTRAN_SHA256" != "$KNOWN_SHA256" ]; then
echo "SHA256 mismatch for gfortran.tar.gz"
echo "expected: $KNOWN_SHA256"
echo "got: $GFORTRAN_SHA256"
exit 1
fi
mkdir -p gfortran_installed/
tar -xv -C gfortran_installed/ -f gfortran.tar.gz
export FC=$(pwd)/gfortran_installed/bin/gfortran
export PATH=$(pwd)/gfortran_installed/bin:$PATH
# link libgfortran.5.dylib, libgfortran.dylib, libquadmath.0.dylib, libquadmath.dylib
# and place them in $HOME/.local/lib, and then change rpath
# to $HOME/.local/lib
for lib in libgfortran.5.dylib libgfortran.dylib libquadmath.0.dylib libquadmath.dylib; do
cp $(dirname $(gfortran --print-file-name=$lib))/$lib $HOME/.local/lib
install_name_tool -id $HOME/.local/lib/$lib $HOME/.local/lib/$lib
install_name_tool -change $(dirname $(gfortran --print-file-name=$lib))/$lib $HOME/.local/lib/$lib $HOME/.local/lib/libgfortran.5.dylib
install_name_tool -change $(dirname $(gfortran --print-file-name=$lib))/$lib $HOME/.local/lib/$lib $HOME/.local/lib/libgfortran.dylib
install_name_tool -change $(dirname $(gfortran --print-file-name=$lib))/$lib $HOME/.local/lib/$lib $HOME/.local/lib/libquadmath.0.dylib
install_name_tool -change $(dirname $(gfortran --print-file-name=$lib))/$lib $HOME/.local/lib/$lib $HOME/.local/lib/libquadmath.dylib
done
export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)}
python -m pip install cmake wget
python scripts/install_KLU_Sundials.py
CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()"

Expand Down Expand Up @@ -182,7 +209,7 @@ jobs:
env:
MACOSX_DEPLOYMENT_TARGET: 11.1
CIBW_BEFORE_BUILD: python -m pip install cmake casadi setuptools wheel delocate
CIBW_REPAIR_WHEEL_COMMAND: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()"

- name: Upload wheels for macOS arm64
Expand Down

0 comments on commit 2affb9d

Please sign in to comment.