Open jmwright opened 10 months ago
Hey @jmwright I tried to use the cqgridfinity
python package which needs cadquery
.
After I successfully installed the arm64 cad query wheel from https://github.com/jdegenstein/ocp-build-system/releases/tag/7.7.2_macos_arm64 I stumbled over the same issue with nlopt
.
On my search I found this issue.
There are three other issues linked, which got all closed.
I hoped to find a solution there, but all issues with nlopt
got "solved" by replacing it with scipy
.
I gave it a try, but I was not successful so far.
The question I am asking myself now, what kind of approach would be more promising: Either to replace nlopt
with scipy
or try to contribute to nlopt
and make it work on arm64?
There is already a two year old issue which mentions the problem with the M1 processors.
I also succesfully tested those, thanks for providing those wheels. nlopt didn't act up for me, installed just fine out of the box via pip (Python 3.12.1).
I used also Python 3.12.1 but on my Macbook Pro with M1 processor.
But if I want to install nlopt
with
pip install nlopt
I get the error message
ERROR: Could not build wheels for nlopt, which is required to install pyproject.toml-based projects
I found this comment which deactivates some options to compile nlopt
:
I am able to run on an M2 MacBook Pro by following the NLopt steps (although slightly modified):
- Open terminal and cd to desired directory (e.g. Documents).
- git clone https://github.com/stevengj/nlopt.git
- cd nlopt
- mkdir build
- cd build
- cmake .. -DNLOPT_OCTAVE=Off -DNLOPT_MATLAB=Off -DNLOPT_GUILE=Off
- make
- sudo make install
If you need a CMakeLists.txt template please refer to my comment on #502.
@thasti do you also used an arm architecture?
Hi. Indeed, I'm on an M2 Air running Fedora Asahi Remix. nlopt simply installs from wheels for me (i.e. is not compiled locally), no issues:
(venv_nlopt) [thasti@slab tmp]$ pip install nlopt
Collecting nlopt
Using cached nlopt-2.6.2-cp312-cp312-linux_aarch64.whl
Collecting numpy>=1.14 (from nlopt)
Obtaining dependency information for numpy>=1.14 from https://files.pythonhosted.org/packages/79/f8/97f10e6755e2a7d027ca783f63044d5b1bc1ae7acb12afe6a9b4286eac17/numpy-1.26.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata
Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.3/62.3 kB 1.9 MB/s eta 0:00:00
Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.9/13.9 MB 33.7 MB/s eta 0:00:00
Installing collected packages: numpy, nlopt
Successfully installed nlopt-2.6.2 numpy-1.26.4
Nonetheless, I tried and I also have no troubles following the step-by-step instructions above without disabling anything (i.e. I just run cmake ..
instead of cmake .. -DNLOPT_OCTAVE=Off -DNLOPT_MATLAB=Off -DNLOPT_GUILE=Off
) and it builds just fine.
Edit: In other words, this looks like it's a MacOS (operating system) issue more than an ARM64 (processor architecture) issue. The issue here concerns only Linux aarch64 wheels, not macOS ones as far as I understand it.
Alright, that is good to know. Thanks for testing :)
I tested now the the commands to build (is this the right term? ^^') nlopt
.
These commands worked for me, but if I try to install nlopt
in my virtual environment with pip install nlopt
it crashes again with this error
$ (.venv) pip install nlopt
Collecting nlopt
Using cached nlopt-2.6.2.tar.gz (2.0 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.14 in ./.venv/lib/python3.12/site-packages (from nlopt) (1.26.4)
Building wheels for collected packages: nlopt
Building wheel for nlopt (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for nlopt (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [261 lines of output]
running bdist_wheel
running build
running build_ext
cmake version 3.28.3
These are only the first lines. In the collapsed section you can find the whole output.
Feel free to continue the discussion here, but it might be more efficient to ask on the nlopt issue tracker.
Not obvious to me what is going wrong with your build. I would also suggest you take your problem to the nlopt issue tracker (https://github.com/stevengj/nlopt/issues) since this seems unrelated to Linux aarch64 discussed here, people are more likely to be able to help you there.
@adam-urbanczyk let me know if any other tests would be useful for you. Can you confirm the issue you had with nlopt on linux aarch64 has been resolved in the meantime or do you still see failures?
I have not been able to get around the Python 3.12 problem on Debían 12 aarch64 running on a Pinebook Pro, and I also tried on a Rock Pro 64 running the same distro. However, I have not tried with the different cmake options listed above. @hf-krechan Is it possible that the proper nlopt and nlopt-dev packages are not installed via your distro's package manager that would allow nlopt to build locally with the new cmake options? If that is not the remaining issue, I think the nlopt issue tracker is the best place for this (as mentioned above).
I did not know that you can also install nlopt with a package manager.
On macOS I use homebrew and there is a nlopt
package: https://formulae.brew.sh/formula/nlopt#default
But the pip install nlopt
command still fails.
I will move to the nlopt issue tracker with this problem.
Do you have some opinions about the idea to replace nlopt
with scipy
?
As far as I see it get's only used in the sketch_solver.py
module.
Do you have some opinions about the idea to replace nlopt with scipy?
@adam-urbanczyk Will probably have better insight on that. I am fine sticking with nlopt and contributing to that package unless there are other compelling reasons to switch.
Definitely not scipy. Long term we should switch to casadi (i.e. what is used by the assy solver) or get rid of the sketch solver completely.
I don't understand what precisely are we discussing here. It does not look like a nlopt issue per se. It uses CMake and not pip for building... Maybe try the offical way first.
BTW conda-forge seems to have a aarch64/arm64 nlopt pacakges also for py3.12.
I thought the topic would be the issue to install cadquery
on an ARM64 machines.
I am not familiar with conda and I am a little bit afraid to crash my Python setup which I need for work.
I will try find a way to install the nlopt-python
on macOS.
Thanks for all your inputs ☺️
FYI mamba/conda is the best supported way to install cadquery, install to a local dir if you are afraid of side effects: https://cadquery.readthedocs.io/en/latest/installation.html#install-the-conda-package-manager
Thanks for this hint. I tried it and it worked :) And I learned a lot about Anaconda, Conda, Miniforge and Mamba 😄
Linux aarch64 and MacOS ARM64 wheels have been attached to the ocp-build-system 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
.
See the announcement on the ocp-build-system repo. You will need to download the cadquery-ocp wheel for your version of Python, and do a local install. In that shared directory there is also a requirements.txt file that contains the CadQuery dependencies so that you can try to hack together a working CadQuery install. However, there are some challenges.
If someone in the community can help figure out the issue with nlopt compilation, that would be great.
If you are interested, please hack around and let me know what you find. Use
pip install -r requirements.txt
to install the dependencies in your Python environment after doing a local install of the cadquery-ocp wheel.