Skip to content

Commit 56af6c8

Browse files
jameskermodeclaude
andauthored
Fix macOS wheel bundling by setting DYLD_LIBRARY_PATH for delocate (#698)
* Fix macOS and Linux wheel bundling with library paths The wheels were broken because delocate (macOS) and auditwheel (Linux) couldn't find QUIP shared libraries during wheel repair. Fix for macOS: - Add QUIP_LIB_PATH environment variable with paths to QUIP libraries - Set DYLD_LIBRARY_PATH in the repair command so delocate can find them - Remove the fallback that produced broken wheels Fix for Linux: - Add LD_LIBRARY_PATH with QUIP library paths so auditwheel can find them 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix GITHUB_WORKSPACE not expanding in cibuildwheel environment Use CIBW_ENVIRONMENT_PASS_MACOS to pass through GITHUB_WORKSPACE so it's available when constructing QUIP_LIB_PATH for the delocate repair command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix delocate duplicate libgfortran detection Find GCC's libgfortran.5.dylib location and put it first in DYLD_LIBRARY_PATH so delocate finds it from only one consistent location, avoiding the "Already planning to copy library with same basename" error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Use brew --prefix to find GCC library path The find command was failing silently. Use brew --prefix gcc which is more reliable on GitHub Actions macOS runners. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Set MACOSX_DEPLOYMENT_TARGET=14.0 to match Homebrew libraries The Homebrew-installed gcc and openblas libraries on macOS 14 runners have a minimum target of macOS 14.0. Without setting this, delocate fails with: "Library dependencies do not satisfy target MacOS version 11.0" Tested locally: delocate successfully bundles all QUIP and Fortran libraries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Use runner-specific MACOSX_DEPLOYMENT_TARGET - macos-14 (ARM64): Homebrew libs need macOS 14.0 - macos-15-intel (x86_64): Homebrew libs need macOS 15.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent e09d3eb commit 56af6c8

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

.github/workflows/build-wheels.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
echo "Updated quippy/meson.build:"
4848
head -5 quippy/meson.build
4949
50-
- name: Determine architecture
50+
- name: Determine architecture and deployment target
5151
id: arch
5252
run: |
5353
if [ "$RUNNER_OS" == "Linux" ]; then
@@ -56,8 +56,10 @@ jobs:
5656
# macos-15-intel is x86_64, macos-14 is arm64
5757
if [[ "${{ matrix.os }}" == "macos-14" ]]; then
5858
echo "arch=arm64" >> $GITHUB_OUTPUT
59+
echo "macos_target=14.0" >> $GITHUB_OUTPUT
5960
else
6061
echo "arch=x86_64" >> $GITHUB_OUTPUT
62+
echo "macos_target=15.0" >> $GITHUB_OUTPUT
6163
fi
6264
fi
6365
@@ -109,22 +111,26 @@ jobs:
109111
meson compile -C builddir
110112
111113
# Set environment variables for builds
112-
# Linux: Set PKG_CONFIG_PATH to where openblas.pc is installed
114+
# Linux: Set PKG_CONFIG_PATH and LD_LIBRARY_PATH for auditwheel to find QUIP libraries
113115
CIBW_ENVIRONMENT_LINUX: >
114116
PKG_CONFIG_PATH="/usr/lib64/pkgconfig:/usr/local/lib64/pkgconfig"
117+
LD_LIBRARY_PATH="/project/builddir/src/libAtoms:/project/builddir/src/fox:/project/builddir/src/GAP:/project/builddir/src/Potentials:/project/builddir/src/Utils:$LD_LIBRARY_PATH"
115118
116-
# macOS: Add paths for openblas
119+
# macOS: Pass through GITHUB_WORKSPACE and set library paths
120+
# Set MACOSX_DEPLOYMENT_TARGET to match the runner's Homebrew libraries
121+
CIBW_ENVIRONMENT_PASS_MACOS: "GITHUB_WORKSPACE"
117122
CIBW_ENVIRONMENT_MACOS: >
118123
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
119124
PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig:/usr/local/opt/openblas/lib/pkgconfig"
125+
MACOSX_DEPLOYMENT_TARGET="${{ steps.arch.outputs.macos_target }}"
126+
QUIP_LIB_PATH="${GITHUB_WORKSPACE}/builddir/src/libAtoms:${GITHUB_WORKSPACE}/builddir/src/fox:${GITHUB_WORKSPACE}/builddir/src/GAP:${GITHUB_WORKSPACE}/builddir/src/Potentials:${GITHUB_WORKSPACE}/builddir/src/Utils"
120127
121-
# macOS: Custom repair command to handle duplicate libgfortran libraries
122-
# delocate has issues with multiple libgfortran.dylib paths from QUIP's multiple libraries
123-
# Try repair with arch check, then without, then skip repair (copy wheel as-is)
128+
# macOS: Custom repair command to bundle QUIP libraries into wheel
129+
# Find GCC lib path via brew, set DYLD_LIBRARY_PATH for delocate to find all libs
124130
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
125-
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} ||
126-
delocate-wheel -w {dest_dir} -v {wheel} ||
127-
cp {wheel} {dest_dir}/
131+
GCC_LIB="$(brew --prefix gcc)/lib/gcc/current" &&
132+
DYLD_LIBRARY_PATH="${GCC_LIB}:${QUIP_LIB_PATH}"
133+
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
128134
129135
# Build with meson-python (already configured in pyproject.toml)
130136
CIBW_BUILD_FRONTEND: "build"

0 commit comments

Comments
 (0)