Skip to content

Mac ARM wheels #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Mac ARM wheels #83

wants to merge 1 commit into from

Conversation

alugowski
Copy link
Collaborator

@alugowski alugowski commented Apr 29, 2023

Build both x86 and ARM wheels on macOS.

This fills the one remaining gap in the approach that was already there: the install name of libomp. It turns out that universal2 dylibs are just two libraries effectively joined together, all the metadata is separate. So the install name of the ARM copy was different from the x86 copy (because brew installs ARM and x86 to different locations). This meant that the relocation/repair into the wheel would only work for the x86 portion, leaving the ARM portion unrelocated, meaning libomp would not be found at runtime.

The rest of the approach is as before. Construct a universal2 version of libomp and build a universal2 version of libgraphblas. The rest is cross-compiled by cibuildwheel.

We could easily build a universal2 wheel instead of separate x86 and arm, but some sources are suggesting better compatibility with old pip with separate wheels.

When github/roadmap#528 is available (currently listed as Q4 2023) then a native build will be a better choice.

Note that as of today there is no way to automatically test Apple Sillicon wheels via GitHub Actions. The x86 runner cannot test them (ARM chips can run x86 code via Rosetta2, but not vice versa). This will remain true until the native ARM runners are available. However nearly all possible issues will show up in the x86 wheels too.

See #81

@alugowski
Copy link
Collaborator Author

Works on my M1 laptop.

Install:

(venv) notchie ~/temp (:|✔) % pip install ~/Downloads/artifact/suitesparse_graphblas-7.4.4.0-cp311-cp311-macosx_11_0_arm64.whl
Processing /Users/enos/Downloads/artifact/suitesparse_graphblas-7.4.4.0-cp311-cp311-macosx_11_0_arm64.whl
Collecting cffi>=1.11 (from suitesparse-graphblas==7.4.4.0)
  Using cached cffi-1.15.1-cp311-cp311-macosx_11_0_arm64.whl (174 kB)
Collecting numpy>=1.19 (from suitesparse-graphblas==7.4.4.0)
  Using cached numpy-1.24.3-cp311-cp311-macosx_11_0_arm64.whl (13.8 MB)
Collecting pycparser (from cffi>=1.11->suitesparse-graphblas==7.4.4.0)
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Installing collected packages: pycparser, numpy, cffi, suitesparse-graphblas
Successfully installed cffi-1.15.1 numpy-1.24.3 pycparser-2.21 suitesparse-graphblas-7.4.4.0
(venv) notchie ~/temp (:|✔) % python
Python 3.11.2 (main, Feb 16 2023, 02:55:59) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import suitesparse_graphblas
>>>

tests:

(venv) notchie ~/temp/venv/lib/python3.11/site-packages/suitesparse_graphblas/tests (:|✔) % pytest
==================================== test session starts =====================================
platform darwin -- Python 3.11.2, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/xyz/temp/venv/lib/python3.11/site-packages/suitesparse_graphblas/tests
collected 8 items

test_doctest.py .                                                                      [ 12%]
test_exceptions.py .                                                                   [ 25%]
test_io.py ...                                                                         [ 62%]
test_package.py ..                                                                     [ 87%]
test_scalar.py .                                                                       [100%]

===================================== 8 passed in 0.28s ======================================
(venv) notchie ~/temp/venv/lib/python3.11/site-packages/suitesparse_graphblas/tests (:|✔) %

@eriknw
Copy link
Member

eriknw commented Apr 29, 2023

Cool! Adam, man, how did you become so awesome? You'll have to let me get you a coffee/mean/drink next time we're in the same neighborhood. As before, this is greatly appreciated.

Interesting approach. So, this currently builds a universal version of SuiteSparse:GraphBLAS that is then used by both arm64 and x86_64, right?

We could easily build a universal2 wheel instead of separate x86 and arm, but some sources are suggesting better compatibility with old pip with separate wheels.

This matches my understanding as well. Better to split the wheels.

LGTM as far as I can tell. @jim22k care to take a peek? We should probably do an alpha release to let us test more thoroughly.

@alugowski
Copy link
Collaborator Author

:)

Interesting approach. So, this currently builds a universal version of SuiteSparse:GraphBLAS that is then used by both arm64 and x86_64, right?

Correct.

@alugowski alugowski mentioned this pull request May 2, 2023
@eriknw
Copy link
Member

eriknw commented May 3, 2023

Closing, b/c/ these changes were included in #84. Thanks again!

@eriknw eriknw closed this May 3, 2023
@alugowski alugowski deleted the arm branch May 4, 2023 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants