diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 740c0766dd..c9c404da1e 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -139,7 +139,9 @@ jobs: env: CIBW_BEFORE_BUILD_MACOS: > python -m pip install --upgrade cmake casadi setuptools wheel - CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} + CIBW_REPAIR_WHEEL_COMMAND_MACOS: | + python scripts/fix_macos_wheel.py + delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()" - name: Upload wheels for ${{ matrix.os }} @@ -173,7 +175,9 @@ jobs: run: python -m pipx run cibuildwheel --output-dir wheelhouse env: 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: | + python scripts/fix_libomp_rpath_macos.py + 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 diff --git a/scripts/fix_libomp_rpath_macos.py b/scripts/fix_libomp_rpath_macos.py new file mode 100644 index 0000000000..6f92719645 --- /dev/null +++ b/scripts/fix_libomp_rpath_macos.py @@ -0,0 +1,19 @@ +# A helper script to fix the rpath of the OpenMP dynamic library. This +# is to be used when building the wheels for PyBaMM on macOS (on both +# amd64 and arm64 architectures). + +import os +import subprocess + +homedir = os.path.expanduser("~") +libomp_path = os.path.join(homedir, ".local/lib/libomp.dylib") + +subprocess.run( + [ + "install_name_tool", + "-change", + "/usr/local/lib/libomp.dylib", + libomp_path, + libomp_path, + ] +)