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 b5d20cd
Showing 1 changed file with 45 additions and 15 deletions.
60 changes: 45 additions & 15 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/[email protected]
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,50 @@ jobs:
run: pipx run cibuildwheel --output-dir wheelhouse
env:
MACOSX_DEPLOYMENT_TARGET: 11.1
CIBW_BEFORE_BUILD_MACOS: >
python -m pip install --upgrade cmake casadi setuptools wheel
# Sourced from
# https://github.com/scipy/scipy/blob/f2d4775e7762fad984f8f0acd8227c725ff21630/tools/wheels/cibw_before_build_macos.sh#L23-L49
CIBW_BEFORE_ALL_MACOS: |
set -e -x
# 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/gfortran-darwin-x86_64-native/bin/gfortran
export PATH=$(pwd)/gfortran_installed/gfortran-darwin-x86_64-native/bin:$PATH
# link libgfortran.5.dylib, libgfortran.dylib, libquadmath.0.dylib, libquadmath.dylib, libgcc_s.1.dylib, libgcc_s.1.1.dylib
# and place them in $HOME/.local/lib, and then change rpath
# to $HOME/.local/lib
mkdir -p $HOME/.local/lib
lib_dir=$(pwd)/gfortran_installed/gfortran-darwin-x86_64-native/lib
for lib in libgfortran.5.dylib libgfortran.dylib libquadmath.0.dylib libquadmath.dylib libgcc_s.1.dylib libgcc_s.1.1.dylib; do
cp $lib_dir/$lib $HOME/.local/lib/
install_name_tool -id $HOME/.local/lib/$lib $HOME/.local/lib/$lib
# can be removed I think
# install_name_tool -change $lib_dir/$lib $HOME/.local/lib/$lib $HOME/.local/lib/libgfortran.5.dylib
# install_name_tool -change $lib_dir/$lib $HOME/.local/lib/$lib $HOME/.local/lib/libgfortran.dylib
# install_name_tool -change $lib_dir/$lib $HOME/.local/lib/$lib $HOME/.local/lib/libquadmath.0.dylib
# install_name_tool -change $lib_dir/$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_BEFORE_BUILD_MACOS: python -m pip install --upgrade cmake casadi setuptools wheel delocate
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 +212,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 b5d20cd

Please sign in to comment.