From e7b7591294ccd3a290989c2736be8dbe30950826 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Mon, 23 Nov 2026 03:55:53 -0600 Subject: [PATCH 1/2] macOS wheels: bundle conda-forge's libomp and pin the deployment target The wheels bundle libomp, so they can't support an older macOS than it does, and wheels.yml took the deployment target from Homebrew's libomp, which is built for the runner's macOS. Since the arm64 job moved to macos-15, the arm64 wheels have needed macOS 15 (macosx_15_0_arm64 from 10.5.1.1), and pip on macOS 12 to 14 arm64 builds the sdist instead. Take llvm-openmp from conda-forge (it supports macOS 11.0 and later) through micromamba, as scikit-learn does, and pin the deployment target per job: 12.0 on arm64, as SciPy and scikit-learn use, and 14.0, as now, on x86_64. suitesparse.sh takes the libomp prefix in LIBOMP_PREFIX (BREW_LIBOMP=1 still means Homebrew's) and adds an rpath to it, since conda-forge's libomp has the install name @rpath/libomp.dylib. --- .github/workflows/wheels.yml | 36 ++++++++++++++------- suitesparse.sh | 16 ++++++--- suitesparse_graphblas/tests/test_package.py | 2 +- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 78b8093..7048c0f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -99,15 +99,16 @@ jobs: cibw_skip: "*many*" # macOS x86_64 — macos-15-intel is the last Intel macOS runner. - # libomp from Homebrew determines the minimum supported macOS version. + # macos_deployment_target is the oldest macOS the wheels support (see "Install + # tools (macOS)" below); the runner's own macOS doesn't matter. - os: macos-15-intel cibw_archs: "x86_64" + macos_deployment_target: "14.0" - # macOS Apple Silicon - # Keep runner version as old as possible: libomp determines minimum macOS version. - # macos-14 is retired on 2026-11-02 (and fails jobs during brownouts before then). + # macOS Apple Silicon. 12.0, as SciPy and scikit-learn use. - os: macos-15 cibw_archs: "arm64" + macos_deployment_target: "12.0" # WebAssembly for Pyodide (PEP 783 `pyemscripten_*` wheels). GraphBLAS is built in # before-build (see CIBW_*_PYODIDE below). @@ -146,17 +147,27 @@ jobs: run: echo "GB_VERSION_REF=$GITHUB_REF" >> "$GITHUB_ENV" shell: bash + - uses: mamba-org/setup-micromamba@d7c9bd84e824b79d2af72a2d4196c7f4300d3476 # v3.0.0 + if: contains(matrix.os, 'macos') + with: + micromamba-version: '2.8.1-0' + - name: Install tools (macOS) if: contains(matrix.os, 'macos') - # Install coreutils which includes `nproc` used by `make -j` in suitesparse.sh + # coreutils has `nproc`, which suitesparse.sh uses for `make -j`. # - # Explicitly install libomp to be clear about the dependency. - # - # libomp determines the minimum macOS version that we can build for + # The wheels bundle libomp (delocate copies it in), so they can't support an older + # macOS than it does. Homebrew's libomp is built for the runner's macOS (15 on + # macos-15), so take conda-forge's llvm-openmp, which supports macOS 11.0 and later. + env: + DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }} run: | brew fetch --retry coreutils && brew install coreutils - brew fetch --retry libomp && brew reinstall libomp - echo "MACOSX_DEPLOYMENT_TARGET=$(otool -l "$(brew --prefix libomp)/lib/libomp.dylib" | grep minos | awk '{print $2}')" >> "$GITHUB_ENV" + prefix="$RUNNER_TEMP/libomp" + micromamba create --yes --prefix "$prefix" --override-channels --channel conda-forge "llvm-openmp=23.1.6" + otool -l "$prefix/lib/libomp.dylib" | grep -A3 LC_BUILD_VERSION + echo "LIBOMP_PREFIX=$prefix" >> "$GITHUB_ENV" + echo "MACOSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET" >> "$GITHUB_ENV" - uses: pypa/cibuildwheel@f9b966cfadf4109556cadc5bb39ddb72d0ce664e # v4.3.5 with: @@ -205,9 +216,10 @@ jobs: # CMAKE_GNUtoMS=ON asks suitesparse.sh to build libraries in MSVC style on Windows. CIBW_ENVIRONMENT_WINDOWS: CMAKE_GNUtoMS=ON GRAPHBLAS_PREFIX="C:/GraphBLAS" - # macOS libomp requires special configs. BREW_LIBOMP=1 asks suitesparse.sh to include them. + # macOS: suitesparse.sh finds libomp through LIBOMP_PREFIX (set above), and + # MACOSX_DEPLOYMENT_TARGET (also set above) applies to GraphBLAS and the wheels. # SUITESPARSE_MACOS_ARCH asks to build a particular architecture. Either x86 or arm64. - CIBW_ENVIRONMENT_MACOS: BREW_LIBOMP="1" SUITESPARSE_MACOS_ARCH=${{ matrix.cibw_archs }} + CIBW_ENVIRONMENT_MACOS: SUITESPARSE_MACOS_ARCH=${{ matrix.cibw_archs }} # Uncomment to only build CPython wheels # CIBW_BUILD: "cp*" diff --git a/suitesparse.sh b/suitesparse.sh index c784656..3a4842b 100755 --- a/suitesparse.sh +++ b/suitesparse.sh @@ -46,13 +46,19 @@ cmake_params+=(-DSUITESPARSE_USE_STRICT=ON) cmake_params+=(-DSUITESPARSE_USE_CUDA=OFF) cmake_params+=(-DSUITESPARSE_USE_FORTRAN=OFF) -if [ -n "${BREW_LIBOMP}" ]; then - # macOS OpenMP flags. - # FindOpenMP doesn't find brew's libomp, so set the necessary configs manually. - cmake_params+=(-DOpenMP_C_FLAGS="-Xclang -fopenmp -I$(brew --prefix libomp)/include") +# macOS: Apple's clang has no OpenMP runtime. LIBOMP_PREFIX is a prefix with include/omp.h +# and lib/libomp.dylib (the wheels use conda-forge's llvm-openmp); BREW_LIBOMP=1 uses Homebrew's. +if [ -n "${BREW_LIBOMP}" ] && [ -z "${LIBOMP_PREFIX}" ]; then + LIBOMP_PREFIX="$(brew --prefix libomp)" +fi +if [ -n "${LIBOMP_PREFIX}" ]; then + # FindOpenMP doesn't look there, so set the necessary configs manually. + cmake_params+=(-DOpenMP_C_FLAGS="-Xclang -fopenmp -I${LIBOMP_PREFIX}/include") cmake_params+=(-DOpenMP_C_LIB_NAMES="libomp") cmake_params+=(-DOpenMP_libomp_LIBRARY="omp") - LDFLAGS="-L$(brew --prefix libomp)/lib" + # The rpath is for conda-forge's libomp, whose install name is @rpath/libomp.dylib: without + # it, delocate can't find the library to copy into the wheel. + LDFLAGS="-L${LIBOMP_PREFIX}/lib -Wl,-rpath,${LIBOMP_PREFIX}/lib" export LDFLAGS if [ -n "${SUITESPARSE_MACOS_ARCH}" ]; then diff --git a/suitesparse_graphblas/tests/test_package.py b/suitesparse_graphblas/tests/test_package.py index 99563cb..4fe0bb7 100644 --- a/suitesparse_graphblas/tests/test_package.py +++ b/suitesparse_graphblas/tests/test_package.py @@ -26,7 +26,7 @@ def test_openmp(): # builds a working, but serial, library, so a serial build is invisible # from the outside: conda-forge's graphblas 10.5.0 shipped that way on # osx-arm64. Wheels build GraphBLAS from source in suitesparse.sh, where - # macOS has to point CMake at Homebrew's libomp by hand, so the same slip + # macOS has to point CMake at libomp by hand, so the same slip # is possible here. val_ptr = ffi.new("int32_t*") info = lib.GrB_Global_get_INT32(lib.GrB_GLOBAL, val_ptr, lib.GxB_LIBRARY_OPENMP) From 259b98a0fdf0273926cfb61124023ed1430ee3b2 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Mon, 23 Nov 2026 03:58:30 -0600 Subject: [PATCH 2/2] wheels.yml: log the llvm-openmp build the macOS jobs install The pin is on the version only, so print the package list, which has the build string, next to the library's minimum macOS. --- .github/workflows/wheels.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7048c0f..c34ab1e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -165,6 +165,8 @@ jobs: brew fetch --retry coreutils && brew install coreutils prefix="$RUNNER_TEMP/libomp" micromamba create --yes --prefix "$prefix" --override-channels --channel conda-forge "llvm-openmp=23.1.6" + # The build string (the pin is on the version only) and the minimum macOS it supports + micromamba list --prefix "$prefix" otool -l "$prefix/lib/libomp.dylib" | grep -A3 LC_BUILD_VERSION echo "LIBOMP_PREFIX=$prefix" >> "$GITHUB_ENV" echo "MACOSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET" >> "$GITHUB_ENV"