Skip to content

Commit

Permalink
Fix rpath for libomp dylib at wheel repair
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed May 15, 2024
1 parent b55169c commit 6fb8ef0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions scripts/fix_libomp_rpath_macos.py
Original file line number Diff line number Diff line change
@@ -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,
]
)

0 comments on commit 6fb8ef0

Please sign in to comment.