Add macOS support - #20
Open
Jim Garrison (garrison) wants to merge 1 commit into
Open
Conversation
Declare Linux and macOS in the trove classifiers, and extend the test matrix to cover both. The workflow now splits the dependency step by `runner.os`, following qiskit-c-api-demo's test_latest_versions.yml: apt on Linux, Homebrew on macOS. The macOS side additionally installs libomp, since Apple clang ships without OpenMP. `fail-fast: false` keeps one failing cell from hiding the state of the rest of the matrix. Three things in setup.py's existing Darwin branch would have kept that new matrix half from building: - The Homebrew paths were hardcoded to /opt/homebrew, which is correct on Apple silicon and wrong on Intel. Ask `brew --prefix` instead, keeping the old value as the fallback when brew is absent. - The rpath used `-Wl,--rpath`, a GNU ld spelling Apple's linker rejects. Both linkers accept `-Wl,-rpath`, so use that on both. - The Darwin branch replaced extra_link_args wholesale and so emitted no rpath at all, leaving the keg-only libomp and openblas dylibs unresolvable at import time. It now derives rpath entries over its own library dirs; it cannot reuse extra_link_args directly, because the bare `-fopenmp` in there is rejected by Apple clang at link time too. Also drop the duplicate `-lomp` (`libraries` already supplies it), add -DOMPI_SKIP_MPICXX to match the Linux branch, and hoist `import platform` to the top now that two places use it. Verified on Linux that the rpath change is not a regression: the built extension still carries RUNPATH, and `tox -e py` and `tox -e mpi` pass. Assisted-by: Claude Opus 5
Jim Garrison (garrison)
marked this pull request as ready for review
September 9, 2026 20:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Declares Linux and macOS in the trove classifiers, and extends the test matrix to cover both.
Test matrix
test_latest_versions.ymlnow splits the dependency step byrunner.os, following the pattern in qiskit-c-api-demo'stest_latest_versions.yml: apt on Linux, Homebrew on macOS. The macOS side installs libomp in addition to the Linux set, since Apple clang ships without OpenMP support.The matrix goes from 5 cells to 10 (
ubuntu-latestandmacos-latest× Python 3.10–3.14).fail-fast: falseis added so that one failing cell doesn't hide the state of the rest — worth having now that a break could be specific to one OS.setup.py fixes
There was already a
platform.system() == 'Darwin'branch for the CPU extension, but three things in it would have kept the new macOS cells from building:/opt/homebrew. That is right on Apple silicon and wrong on Intel. It now asksbrew --prefix, falling back to the old value whenbrewisn't onPATH.-Wl,--rpath, a GNU ld spelling that Apple's linker rejects. Both linkers accept-Wl,-rpath, so that form is now used on both platforms.extra_link_argswholesale and so emitted no rpath at all, which leaves the keg-only libomp and openblas dylibs unresolvable at import time. It now derives rpath entries over its own library dirs. It can't just reuseextra_link_args, because the bare-fopenmpin there is rejected by Apple clang at link time the same way it is when compiling.Also drops a duplicate
-lomp(librariesalready supplies it), adds-DOMPI_SKIP_MPICXXto match the Linux branch, and hoistsimport platformto the top of the file now that two places use it.Verification
The rpath spelling change affects Linux as well, so I checked it isn't a regression there: the built extension still carries
RUNPATH, and bothtox -e pyandtox -e mpipass.The macOS cells themselves are unverified until CI runs on this PR — I have no Mac to test on locally, and that is the main thing to watch here.
This PR was generated by Claude Opus 5 under my guidance.