cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

Installing cadquery on macOS on Apple silicon

Open jchidley opened this issue 4 years ago • 9 comments

Is there a way to install the current cadquery python library (the current master) on on an ARM based mac (currently M1)?

It is possible to install both the CQ-editor (binary download, I think) and Jupyter-CadQuery (using Docker) but not the vanilla library, as far as I can tell. I believe that there are no osx-arm64 versions of the packages.

Alternatively, is there a manual way to install the required files, perhaps by compiling them? A quick look suggests that the documentation on this is pretty sparse and that the process will be complex.

jchidley avatar Sep 25 '21 15:09 jchidley

It is a non-trivial task to build CadQuery's dependencies. You are correct that the documentation on this topic is pretty sparse. If you just want to use the library by itself, I have been doing manual assembly of an environment and then using LD_LIBRARY_PATH on MacOS and Linux to make sure the libs are loaded properly. As long as the underlying deps don't change too much, you can just pull the latest from CadQuery master to stay more current.

https://github.com/7BIndustries/Semblage/blob/master/.github/workflows/tests.yml#L34

jmwright avatar Sep 25 '21 17:09 jmwright

I understood your words @jmwright but I have failed to get to grips with the whole host of libraries and your link to Semblange tests.

Edit: this is a horrible hack but it's all I have at the moment

In the meantime, I have been taking a different route: using Docker and jupyter-cadquery.

Very roughly, you run jupyter-cadquery's docker image, adding -p 8866:8866 for jcv. Then add the Docker extension to Visual Studio before attaching to the jupyter-cadquery container. This installs the required VS Code files. The python extension will need to be added to the container.

Once attached to the container, open a terminal, run conda init then conda activate cq before starting jcv. It'll open a browser window for the viewer.

You'll have to add the python extension to the VS Code editor on the Docker container. Open your python file and then (potentially) open another terminal to run conda activate cq before changing the python interpreter to ('cq': conda).

Finally, you can run the python code and see the results.

jchidley avatar Sep 27 '21 15:09 jchidley

What I need to do, it turns out, is make another docker image.

jchidley avatar Sep 27 '21 18:09 jchidley

@jmwright Are there any plans to support Apple Silicon natively?

tbo avatar Dec 20 '21 17:12 tbo

Are there any plans to support Apple Silicon natively?

I don't think the core team is opposed to it, but I also don't think that any of us has an M1 to develop/test on. I expect we'll run into signing requirements eventually that will require a paid developer account as well. It feels like MacOS is getting more difficult for small open source projects to support as time goes on rather than easier.

jmwright avatar Dec 20 '21 21:12 jmwright

The key requirement is to build a native M1/arm64 OCP with pywrap. This is not trivial--I did build a macOS version of OCP to run on Mojave (10.14) (since the bundled CQ package is built for 10.15+). I do recall having to jump through many hoops to get a successful build--mainly related to C++ library dependencies and versions. I can sympathize with the CQ team that maintaining multiple build pipelines for different platforms is quite a burden. The peculiarities of the Apple toolchain ecosystem centred on Xcode doesn't help!

michaelgale avatar Dec 21 '21 03:12 michaelgale

Building the docker images for AMD64 on Apple M1 does work. It's a bit slow and drains the battery because it's an emulation, and you have docker to deal with too.

I'd prefer a native solution but CadQuery is worth it no matter how tricky the install is.

jchidley avatar Feb 12 '22 23:02 jchidley

I am on an M1 mac running on the VMware Fusion Tech Preview for M1 the OS is Ubuntu 20.04.3 LTS. Does the CICD pipeline support doing arm64 (heh) builds?

miniforge has arm64 builds, install fails at

(cadquery) arm@arm:~$ conda install -c conda-forge -c cadquery cadquery=master
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - cadquery=master

Current channels:

  - https://conda.anaconda.org/conda-forge/linux-aarch64
  - https://conda.anaconda.org/conda-forge/noarch
  - https://conda.anaconda.org/cadquery/linux-aarch64
  - https://conda.anaconda.org/cadquery/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

seanjensengrey avatar Mar 07 '22 08:03 seanjensengrey

I don't think that all of the software is available for arm64 machines, even virtual Linux ones. The only way that I could get this to work on my Mac was to use an AMD64 Docker image --platform=linux/amd64. It might be possible to do the same with your VMWare Fusion instead of Docker.

jchidley avatar Mar 07 '22 11:03 jchidley

@jmwright since I'm in the same boat as others asking for an M1 version: can you elude a little bit to what exactly needs to be done for proper M1 support? After some (admittedly very little) research it seems like the primary problem is getting the OCCT wrapper compiled for M1. If that's the case, is it just that the setup is complicated, or are there closed-source components that would technically prevent an M1 version from being created? If it's the former I'd like to give it a shot.

schluete avatar Oct 07 '22 15:10 schluete

I'm no expert, but I think its the former. Checkout these two links to gain deeper insight

  • https://github.com/CadQuery/OCP/issues/68
  • https://dev.opencascade.org/content/testing-occt-apple-m1-arm64

It would be a dream come true for me to see this closed.

smallstepman avatar Oct 07 '22 15:10 smallstepman

I don't believe that any core developer has access to an M1 Mac for testing, but I think the bigger challenge is the lack of an Mac M1 runner in Azure Pipelines.

https://github.com/microsoft/azure-pipelines-agent/issues/3184

I don't think we are ready to do a self-hosted runner at this time.

https://itnext.io/run-azure-self-hosted-macos-agents-on-apple-m1-mac-72726555d83b

jmwright avatar Oct 07 '22 18:10 jmwright

I was able to install and use cadquery + cq-editor using the rosetta emulation layer. Obviously still not as good as native support, but still a bit better than using a VM or docker.

I used the following commands to get it to run

$ arch -x86_64 brew install miniconda
$ arch -x86_64 conda install -c cadquery -c conda-forge cadquery=master
$ arch -x86_64 conda install -c cadquery -c conda-forge cq-editor=master
$ arch -x86_64 /opt/homebrew/Caskroom/miniconda/base/bin/python

Instead of using arch -x86_64 in front of every command, it's also possible to do something like arch -x86_64 zsh beforehand. Then all commands run in that instance of zsh are run with rosetta.

phillipthelen avatar Nov 29 '22 16:11 phillipthelen

I am currently writing a Dockerfile for compiling OCP for arm64v8/ubuntu:22.04. Compilation and linking works, so far... The OCP.so seems to be functional. next step is to build the occ conda package... then building cadquery... when everything is done I am going to clean it up and push it to dockerhub... Bildschirm­foto 2023-01-13 um 21 55 52

szymansk avatar Jan 13 '23 20:01 szymansk

@szymansk Please report back here when you publish that.

jmwright avatar Jan 14 '23 13:01 jmwright

@jmwright I published arm64v8 linux docker image here: https://hub.docker.com/r/szymanski2adesso/cadquery Thing is... there is currently no view... didn't have time to take a glance ad the visualisation. But we are changing the cq-server to visualise tesselated objects via REST.

I am going to make a fork of OCP and cadquery, where I add the docker file and make a pull-request.

Meanwhile the Dockerfile is here: https://github.com/szymansk/cadquery_arm64/tree/py3.9.15_ocp7.6.3_cadquery2

szymansk avatar Jan 17 '23 11:01 szymansk

arm osx is available via conda-forge

adam-urbanczyk avatar Mar 17 '23 07:03 adam-urbanczyk

@adam-urbanczyk it will work for stable builds only right? (no way to build from master?)

Also cq-editor not here yet right?

ssbb avatar Mar 22 '23 14:03 ssbb

Yes, only releases. All the deps are available, so you can technically install it, but not out of the box.

adam-urbanczyk avatar Mar 22 '23 18:03 adam-urbanczyk

I've been interested in cadquery for a while but never delved in due to being on an M1 (so I've been watching this issue with interest).

Also never been a conda user (and don't really want it modifying my dotfiles). Being new to both cq and conda, I thought I'd share a few steps that got a working M1 jupyter environment for me:

#!/bin/bash

set -Eeuf -o pipefail
set -x

trap 'pkill -fl voila' EXIT

main() {
  . "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh"

  conda deactivate || true
  # uncomment here to rebuild the conda env from scratch
  # conda env remove -n cadquery || true

  conda create \
    -y \
    -n cadquery \
    -c conda-forge \
    -c cadquery \
    python=3.11 \
    cadquery pip

  conda activate cadquery

  python -m pip install jupyter-cadquery cadquery-massembly matplotlib

  jcv &
  jupyter lab
}
main "$@"

This opens the jcv viewer as well as jupyter. If I paste into jupyter:

import cadquery as cq
from jupyter_cadquery.viewer.client import show

length = 80.0
height = 60.0
thickness = 100.0

result = cq.Workplane("XY").box(length, height, thickness)
show(result)

I can open the jcv viewer window and see the box rendered.

If I eventually figure out a plain pip (or nix) install I'll post it here, hope that's okay.

n8henrie avatar Mar 30 '23 21:03 n8henrie

How is this better than https://github.com/CadQuery/cadquery#conda-installation ? You don't need to run conda init and modify any dot files. You can also use something like micromamba

adam-urbanczyk avatar Mar 30 '23 21:03 adam-urbanczyk

Not trying to argue it's better in any way, just new territory for me.

Knowing nothing about conda, I had no idea what miniforge, conda forge, or minimamba are. I do all my python development with the built-in venv module and pip and generally shy away from poetry, pipenv, conda, etc.

It indeed looks like miniforge supports darwin-aarch64, and I'm sure would be a fine way to do things.

n8henrie avatar Mar 30 '23 21:03 n8henrie

Yeah miniforge works great on m1. To not mess with my env I just wrapped miniforge init code in function and call it when I need to work with cadquery

ssbb avatar Mar 30 '23 22:03 ssbb

How is this better than https://github.com/CadQuery/cadquery#conda-installation ? You don't need to run conda init and modify any dot files. You can also use something like micromamba

So does the installation method mentioned here now work on Mac ARM? Just gotta use conda? Going to try to do this in Docker.

mosri avatar Jun 27 '23 19:06 mosri

It should be possible, at least OCP is available for this platform:

osx-arm64 v7.7.0.1 linux-64 v7.7.0.1 win-64 v7.7.0.1 osx-64 v7.7.0.1

adam-urbanczyk avatar Jun 27 '23 20:06 adam-urbanczyk

Anyone willing to help me troubleshoot installing cadquery on macOS Ventura (ARM) in Docker? Been messing with different versions of Conda and python and can't get it to install cadquery.

Also installs python 3.10 even when explicitly install 3.7.

Screenshot 2023-06-28 at 2 35 22 PM

Instructions using from miniforge https://github.com/conda-forge/miniforge image

image

mosri avatar Jun 28 '23 19:06 mosri

Sailing at the moment so I can’t help, sorry

** Jack Chidley @.*** 07764 359921 **


From: @.*** @.> Sent: Wednesday, June 28, 2023 9:50:11 PM To: CadQuery/cadquery @.> Cc: Jack @.>; Author @.> Subject: Re: [CadQuery/cadquery] Installing cadquery on macOS on Apple silicon (#891)

Anything willing to help me troubleshooting installing cadquery an OS X in Docker? Been messing with different versions of Conda and python and can't get it to install cadquery.

[Screenshot 2023-06-28 at 2 35 22 PM]https://user-images.githubusercontent.com/8907920/249595373-9becab26-c617-4a6e-98f4-f32dec91c9d8.png

— Reply to this email directly, view it on GitHubhttps://github.com/CadQuery/cadquery/issues/891#issuecomment-1612012255, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABYOSRORLXFJ5JCNUWRJ6WTXNSDHHANCNFSM5EXXJUCA. You are receiving this because you authored the thread.Message ID: @.***>

jchidley avatar Jun 29 '23 10:06 jchidley

try szymansk/cadquery_arm64

szymansk avatar Jun 29 '23 14:06 szymansk

try szymansk/cadquery_arm64

Did not work for me. I got this error: image

Please someone help me figure this out. I've been trying to get this to work for a really long time. Thank you.

mosri avatar Jul 01 '23 21:07 mosri