Skip to content
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

Add Python builds for Apple Silicon #2663

Closed
lpugin opened this issue Feb 22, 2022 · 14 comments
Closed

Add Python builds for Apple Silicon #2663

lpugin opened this issue Feb 22, 2022 · 14 comments

Comments

@lpugin
Copy link
Contributor

lpugin commented Feb 22, 2022

It seems that this should be available for python 3.8 onwards.
https://cibuildwheel.readthedocs.io/en/stable/

Not sure what to change in the workflow. @musicEnfanthen ?

ahankinson added a commit that referenced this issue Feb 22, 2022
From: https://cibuildwheel.readthedocs.io/en/stable/faq/#apple-silicon

This commit adds specific builds for x86_64 and arm64. It does not add a universal2 option, to try and keep down the library size when installing. 

Refs #2663
@lpugin
Copy link
Contributor Author

lpugin commented Feb 22, 2022

I think we also need to adjust things here

os: [macos-latest, windows-latest, ubuntu-20.04]
python-version: ["3.7", "3.8", "3.9", "3.10"]
architecture: [x86, x64]
include:
- os: macos-latest
architecture: x64
platform_id: macosx_x86_64
- os: windows-latest
architecture: x64
platform_id: win_amd64
- os: windows-latest
architecture: x86
platform_id: win32
- os: ubuntu-20.04
architecture: x64
platform_id: manylinux_x86_64
exclude:
- os: macos-latest
architecture: x86
- os: ubuntu-20.04
architecture: x86

Any ideas what architecture: x64 means here


and why x86 is excluded here

@musicEnfanthen
Copy link
Contributor

the line with architecture: x64 is needed for the setup/python action in the workflow. If I remember correctly, x86 architecture is only supported for Windows runners in the setup/python action, cf. https://github.com/actions/python-versions/blob/main/versions-manifest.json. Because of that, using macos-latest with x86 arch threw an error back then, and had to be excluded.

@musicEnfanthen
Copy link
Contributor

For the arm64 configuration: We could try to skip cibuildwheel on python version below 3.8 which does not support Apple Silicon.

So here:

CIBW_SKIP: cp27-* # manylinux2014 not compatible with python 2.7

it should probably read

CIBW_SKIP: "cp27-* cp37-macosx_arm64" # manylinux2014 not compatible with python 2.7, macosX arm64 not compatible with python < 3.8

Did not test it, so not sure about the syntax with quotation marks, but took it from here: https://cibuildwheel.readthedocs.io/en/stable/options/#examples_1

If that does not work, because cibuildwheel internally would pass the arm64 config to the build step nonetheless, it could be an option to split up the cibuildwheel step in the gh actions workflow into two steps, one for python 3.7 without arm64, and one for python >= 3.8 with arm64 config.

@rettinghaus
Copy link
Contributor

I tested @musicEnfanthen's suggestion here and it seems to work.

@lpugin
Copy link
Contributor Author

lpugin commented Feb 23, 2022

Thanks for trying. I can see only four builds for macos, all seem to be for x86_64. E.g., https://github.com/rettinghaus/verovio/runs/5293392197?check_suite_focus=true#step:6:13

Am I overlooking something? Could you point me to the arm64 build?

@lpugin
Copy link
Contributor Author

lpugin commented Feb 23, 2022

I added the arm64 in the matrix here.
lpugin@820fa56

This fails because python-setup does not seem to support arm64.
https://github.com/lpugin/verovio/runs/5299680915?check_suite_focus=true#step:4:13

See
actions/setup-python#108 (comment)

Can we cross-compile the arm64 wheel from a x64 machine? Or is there a way to install Python differently?

@rettinghaus
Copy link
Contributor

With setup-python you only can install the x64 build, see https://github.com/actions/python-versions/releases
Also, as it stands, there are currently no plans to support M1 environments in GitHub actions.
And I don't think we can cross-compile to arm64 on x64, only the other way round with Rosetta 2.

@lpugin
Copy link
Contributor Author

lpugin commented Feb 23, 2022

Cross-compiling looks possible https://cibuildwheel.readthedocs.io/en/latest/faq/#apple-silicon
I am looking at it.

@rettinghaus
Copy link
Contributor

O yes, at least we have to CIBW_TEST_SKIP: *_arm64.

@lpugin
Copy link
Contributor Author

lpugin commented Feb 23, 2022

Building works https://github.com/lpugin/verovio/runs/5300429546?check_suite_focus=true#step:8:11

I still need to fix the testing which pulls all the wheels. That is different from the CIBW_TEST_SKIP

@musicEnfanthen
Copy link
Contributor

@lpugin Can you try the following change:


      - name: Install from wheel on Unix
        if: always() && runner.os != 'Windows'
        working-directory: wheelhouse
        run: python -m pip install ./*.whl  ## change to  -->  ./*_x86_64.whl

This should exclude the arm64 wheels from the pip install check, since they are not supported on the x64 runners (as you said, at the moment there aren't any arm64 compatible runners in GH actions). At the same time, x64 wheels should pass this check on ubuntu and macosx.

Please be aware that the arm64 wheel needs to be considered "untested" then.

@lpugin
Copy link
Contributor Author

lpugin commented Feb 23, 2022

Thanks. This is what I did and it seems to work https://github.com/lpugin/verovio/runs/5301787587?check_suite_focus=true

@musicEnfanthen
Copy link
Contributor

Perfect :)

@lpugin
Copy link
Contributor Author

lpugin commented Feb 23, 2022

https://test.pypi.org/project/verovio/3.10.0.dev0/#files

@lpugin lpugin closed this as completed Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants