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

Mac arm64 build for 7.7.x #11

Open
bernhard-42 opened this issue Jan 29, 2023 · 47 comments
Open

Mac arm64 build for 7.7.x #11

bernhard-42 opened this issue Jan 29, 2023 · 47 comments

Comments

@bernhard-42
Copy link
Collaborator

According to CadQuery/cadquery#1236 (comment) OCP now can build arm64 libs for Mac as conda packages.
Will Mac arm64 be supported by the upcoming 7.7.x wheel too?

@fpq473
Copy link
Collaborator

fpq473 commented Jan 29, 2023

In theory we could just add it here:

os: [ 'ubuntu-20.04', 'macos-11', 'windows-latest' ]

but are github actions available on macos/arm64? A cursory search suggests no.

@jmwright
Copy link
Member

I saw the other day that support for GitHub-hosted Apple Silicon is in beta and is expected to go public in Q3 2023: github/roadmap#528

They have that conversation locked, probably because so many devs like me would bug them about it when it will be released. They've supported self-hosted M1 runners since August 2022.

The OCP wheel build should support the GitHub-hosted M1 runner when it's available, but we either have to wait until Q3 2023, or somebody has to set up a self-hosted runner.

@bernhard-42
Copy link
Collaborator Author

Hmmm, wasn't aware of this dependency.
Thanks for looking into it!

@fpq473
Copy link
Collaborator

fpq473 commented Apr 18, 2023

@fungiboletus notes in CadQuery/OCP#108 (comment):

A workaround could be about using docker buildx with qemu. It works relatively well in github actions, though you have to build things inside a container and not directly in the action.

@akoen
Copy link

akoen commented Oct 3, 2023

https://github.blog/changelog/2023-10-02-github-actions-apple-silicon-m1-macos-runners-are-now-available-in-public-beta/

@jmwright
Copy link
Member

jmwright commented Oct 4, 2023

Thanks for the heads-up @akoen

@jmwright
Copy link
Member

I tried to enable this runner, unfortunately GitHub does not have a free version for open source projects yet (and I don't know if they have plans to). See the comment here.

@bernhard-42
Copy link
Collaborator Author

@jmwright
I build the M1 wheels for myself using ocp-build-system (and host them in my own pypi server locally)

# size       wheel
  161081972  cadquery_ocp-7.7.1-cp310-cp310-macosx_11_0_arm64.whl
  161082182  cadquery_ocp-7.7.1-cp311-cp311-macosx_11_0_arm64.whl
  161087133  cadquery_ocp-7.7.1-cp39-cp39-macosx_11_0_arm64.whl

I could contribute them, but don't know how my wheels could be integrated into your workflow.

@jmwright
Copy link
Member

jmwright commented Nov 3, 2023

It's not a solution for this issue, but someone posted on the CadQuery repo that they were able to get CadQuery to run on an M1 Mac. CadQuery/cadquery#1434

@jeremiahrose
Copy link
Contributor

jeremiahrose commented Dec 22, 2023

There is no ETA for free osx-arm64 runners from Github and they apparently aren't even working on it at present (source). And there are no linux-aarch64 runners or ETA for them being available.

However, if the Conda package is already being cross compiled to arm64, then surely it would be possible to convert that recipe to Pip and use it in this repo on an intel runner - right?

I'd be happy to assist with this as I really need an easily-installable-with-pip Cadquery for my team.

@jeremiahrose
Copy link
Contributor

Here is the PR that added osx-arm64 to conda: conda-forge/ocp-feedstock#17

@jeremiahrose
Copy link
Contributor

After trying a few different approaches, building locally ended up being the path of least resistance. I'd be happy to do this on a regular basis on my M1 Macbook and upload the wheels to PyPi if that'd be helpful?

PR containing the build script here: #18

@rawwerks
Copy link

just curious if there is a plan to take @jeremiahrose up on his offer (#18), or if i should plan to work around this issue for the foreseeable future.

@jmwright
Copy link
Member

I have Mac M1 wheels built, but I can't upload them to PyPI right now because of size limits. I can make them available via something like a Dropbox download if someone has the capability and interest to install them locally.

@jeremiahrose
Copy link
Contributor

Can we request a size limit increase from PyPI? I hear they do regularly grant them on a case by case basis.

In the meantime I have uploaded 7.7.1.0 to GitHub releases on my fork, you can install directly with:

pip3 install https://github.com/jeremiahrose/ocp-build-system/releases/download/7.7.1.0/cadquery_ocp-7.7.1-cp310-cp310-macosx_11_0_arm64.whl

There are wheels for other Python versions as well

@jmwright
Copy link
Member

I already requested a size increase but have not heard back. We've gotten one increase already.

@KenjiTakahashi
Copy link

KenjiTakahashi commented Jan 15, 2024

FYI: https://www.flyci.net [I'm not affiliated.]

@bernhard-42
Copy link
Collaborator Author

@jmwright Since vtk in the meantime has Mac arm wheels, I wonder if you could remove the vtk libraries from cadquery_ocp. Given the amount of wheels this might free up enough to add another wheel?

@bernhard-42
Copy link
Collaborator Author

Plus I would think about removing the Python 3.8 wheels. 3.9, 3.10, 3.11 and 3.12 should be sufficient in 2024

@jmwright
Copy link
Member

@bernhard-42 We started building and bundling VTK ourselves because the official VTK wheels were built against a libstdc++ that was so new only bleeding-edge distros could run them. If that is no longer an issue we can switch back to the official VTK wheels.

Am I reading this article correctly that Python 3.8 goes EoL during 2024?

@bernhard-42
Copy link
Collaborator Author

I would say that build123d and cadquery are more domain specific languages than generic Python packages that one installs into old Python envs.
As such, I would expect that supporting the latest 4 Python versions from 3.9 onwards should be really sufficient. For example, the newest numpy and pandas also support >= 3.9 only.

If we look at the hassle every arm mac user has to go through at the moment, upgrading from Python 3.8 to 3.9 shouldn't be a big deal.

But that of course are my 2 cent only.

@KenjiTakahashi
Copy link

It's worth noting also that the latest macOS already ships with Python 3.9, so then no need to touch anything even.

@jmwright
Copy link
Member

Related comment on the CadQuery repo about removing Python 3.8 support: CadQuery/cadquery#1498 (comment)

@jmwright
Copy link
Member

FYI: f4c2498

@bernhard-42
Copy link
Collaborator Author

great! Thank you.

@radeva
Copy link

radeva commented Jan 18, 2024

I tried to enable this runner, unfortunately GitHub does not have a free version for open source projects yet
..
After trying a few different approaches, building locally ended up being the path of least resistance.

@jmwright @jeremiahrose You can try FlyCI's M1 and M2 runners. They are on average 2x faster and 2x cheaper than GitHub's AND we have a free tier for OSS projects (see below).

Install Instructions

  1. Install FlyCI app and
  2. Easily replace one line of code and start using FlyCI runners:
jobs:
 ci:
-    runs-on: macos-latest
+    runs-on: flyci-macos-large-latest-m1
   steps:
   - name: 👀 Checkout repo
     uses: actions/checkout@v4

500 mins/month Free for Public Repos

Since your repo is public, FlyCI offers 500 mins/month of free M1 runner usage with the flyci-macos-large-latest-m1 runner for public projects.

Don't hesitate to contact us in case the free tier doesn't suit your needs or you experience any issues with the runners. Our team is here to support you!

Best Regards,
Veselina Radeva
Product Manager at FlyCI

@jdegenstein
Copy link
Collaborator

jdegenstein commented Jan 31, 2024

FYI, Apple Silicon runners are now available for free from GitHub for public repos. Blog post here: https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/

I tested it and it is working great! Oh and thanks to barnaby for letting me know about it!

@jmwright
Copy link
Member

Thanks for letting me know @jdegenstein

Do you have an example of how you used it? I thought I followed the instructions in the blog post, but the GitHub Action is still building x86_64 wheels for me.

@jdegenstein
Copy link
Collaborator

Sure, here is my test run file https://github.com/jdegenstein/build123d/blob/GH_macARM64_onlyPlane/.github/workflows/test.yml

Definitely looks like arm64 to me:
image

@jdegenstein
Copy link
Collaborator

@jmwright I was able to build cadquery-ocp on my fork for MacOS arm64. Long story short, the biggest issue was that conda was creating an "osx-64" env when what was needed was "osx-arm64". There are a number of other minor issues and cleanup but it should provide a starting point at least:

https://github.com/jdegenstein/ocp-build-system/actions/runs/7747906519

I also published a cp310 wheel here:
https://github.com/jdegenstein/ocp-build-system/releases/tag/7.7.2_macos_arm64_cp310

@jmwright
Copy link
Member

jmwright commented Feb 1, 2024

Thanks @jdegenstein . Would you like to do a PR to the main repo? That workflow file is not in use yet, and was added specifically for this purpose, so I can merge it and then do some cleanup. I may switch all the builds to the local build method eventually, but want to be sure to get MacOS ARM64 builds working first.

@hf-krechan
Copy link

Great work @jdegenstein 🚀
Thanks for this setup of the GitHub Action

@jmwright
Copy link
Member

Thanks to @jdegenstein there are now MacOS ARM64 wheel builds in CI: https://github.com/CadQuery/ocp-build-system/actions/runs/7874432399

The wheel files will have to be renamed before uploading to PyPI, but that will have to wait until we get the project size increased there.

Please test these wheels out and report back here if you have any problems.

@jdegenstein
Copy link
Collaborator

Awesome! It would be great if the newly built MacOS ARM64 wheels could be added to a release here on GH as well (that way they can be e.g. pip installed from a URL).

@kdewald
Copy link

kdewald commented Feb 14, 2024

Awesome development! I can't wait to try this out!

@jmwright
Copy link
Member

@jdegenstein I didn't think about users doing a pip install from a specific release/tag. I will try to assemble that release.

@jmwright
Copy link
Member

The MacOS ARM64 wheels have been attached to the release here. It is possible to do a pip install of the wheels on that release by copying the URL for the file that matches your OS and Python version and then doing pip install URL_OF_CORRECT_WHEEL_FILE.

@fferri
Copy link

fferri commented Feb 21, 2024

Any idea why that would not work?

❯ python3 --version
Python 3.11.6
❯ ls -l $(which python3)
/opt/homebrew/bin/python3 -> ../Cellar/[email protected]/3.11.6_1/bin/python3
❯ python3 -m pip install https://github.com/CadQuery/ocp-build-system/releases/download/7.7.2.0/cadquery_ocp-7.7.2-cp311-cp311-macosx_11_0_arm64.whl
Collecting cadquery-ocp==7.7.2
  Downloading https://github.com/CadQuery/ocp-build-system/releases/download/7.7.2.0/cadquery_ocp-7.7.2-cp311-cp311-macosx_11_0_arm64.whl (165.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 165.4/165.4 MB 6.4 MB/s eta 0:00:00
Installing collected packages: cadquery-ocp
Successfully installed cadquery-ocp-7.7.2
❯ python3
Python 3.11.6 (main, Nov  2 2023, 04:39:43) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
>>> import cadquery
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cadquery'
❯ ls -ld /opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/*cadquery*
/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cadquery_ocp-7.7.2.dist-info

@jmwright
Copy link
Member

You need to install the cadquery package as well. cadquery-ocp does not bundle CadQuery with it. It only has a version of OCP that was intended for use with cadquery. We can't make it simply "ocp" because that would cause a naming conflict on PyPI.

@fferri
Copy link

fferri commented Feb 21, 2024

Right, thanks for the clarification.

It works fine on macOS arm64. Thanks for making these packages available!

@infused-kim
Copy link

infused-kim commented Jun 14, 2024

Thank you so much for adding Apple Silicon support. I used the workaround of installing the wheel manually and it's working perfectly.

It looks like pypi increased the storage size to accomodate Apple Silicon builds (pypi/support#3631).

Would it be possible to submit the wheels to pypi?

@jmwright
Copy link
Member

jmwright commented Sep 6, 2024

Please download the correct wheel for your platform and Python version and do a test installation. Once these have been tested, I will publish them to PyPI. During the installation, cadquery-vtk will be downloaded from PyPI since it is no longer embedded inside the OCP wheel.

https://github.com/CadQuery/ocp-build-system/releases/tag/7.7.2.1

@jmwright
Copy link
Member

MacOS ARM64 builds are available for 7.7.2.1 on PyPI now.

https://pypi.org/project/cadquery-ocp/

@bernhard-42
Copy link
Collaborator Author

bernhard-42 commented Sep 10, 2024

Thank you.

Unfortunately I can't test it since the arm build of macos is for version 14.0+ and I have 13.0. The intel build is for macos 13+, but I have arm - LOL

[cadquery_vtk-9.2.6-cp311-cp311-macosx_14_0_arm64.whl ](https://files.pythonhosted.org/packages/91/7b/b378be0f03ad1ef366d47e5be96178b50704765e1ad6e5a5abfe25683031/cadquery_vtk-9.2.6-cp311-cp311-macosx_14_0_arm64.whl)(39.1 MB [view hashes](https://pypi.org/project/cadquery-vtk/#copy-hash-modal-46839a0f-4beb-41ed-9462-bba03c08b631))
Uploaded 28. Aug. 2024 CPython 3.11 macOS 14.0+ ARM64

[cadquery_vtk-9.2.6-cp311-cp311-macosx_13_0_x86_64.whl ](https://files.pythonhosted.org/packages/ff/5e/678d3a26e77aa79d43509abe56e25522d163057e6960fe41697c2e2b90aa/cadquery_vtk-9.2.6-cp311-cp311-macosx_13_0_x86_64.whl)(42.8 MB [view hashes](https://pypi.org/project/cadquery-vtk/#copy-hash-modal-5014bb6b-8b87-4a08-8c95-fe965fcc73cd))
Uploaded 28. Aug. 2024 CPython 3.11 macOS 13.0+ x86-64

Python packaging for binary packages is simply a nightmare ...

@jmwright
Copy link
Member

Python packaging for binary packages is simply a nightmare ...

I 100% agree.

@jdegenstein
Copy link
Collaborator

@jmwright I was able to install cadquery-vtk and it worked perfectly on Win10 / py311. Thank you for the work on this!

I guess I need to investigate if it is possible to build on MacOS14 (arm) for MacOS13 (arm). We are building on MacOS14 to ensure we get arm and not x86_64 (github's approach to this problem seems a little lacking in my opinion, but maybe there is another workaround).

@jmwright
Copy link
Member

There was an issue with the VTK dependency that is causing this wheel not to work properly for certain use cases, so I am reopening this issue.

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

No branches or pull requests