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

How do I install cq in a conda env using pip #1236

Closed
bernhard-42 opened this issue Jan 15, 2023 · 14 comments
Closed

How do I install cq in a conda env using pip #1236

bernhard-42 opened this issue Jan 15, 2023 · 14 comments
Labels
question Further information is requested

Comments

@bernhard-42
Copy link
Contributor

The latest commit prevents from dependencies being installed when in conda env.

On a M1 mac I have my own OCP wheel sitting on a private pypi server, called "banach"

My install process was for an existing conda env:

mamba create -n cq-3.9 python=3.9 ipython jupyterlab matplotlib numpy pandas     # for example, plus any other libs
pip install --pre --trusted-host banach --extra-index-url http://banach:8080/ git+https://github.com/CadQuery/cadquery.git

This now doesn't install any dependencies any more.

Why do I start with conda? Because mambaforge provides M1 arm64 packages that still don't exist sometimes on pypi.

If I fall back to the commit before the change in setup.py it works again

pip install --pre --trusted-host banach --extra-index-url http://banach:8080/ git+https://github.com/CadQuery/cadquery.git@4745ad1cee78923ff38992acc7a4177c37e5f5fe
```bash

This now installs everything from pypi except `cadquery_ocp` which comes from my private pypi server.

Is there a way to still get cadquery installed into a conda env via pip?
@adam-urbanczyk
Copy link
Member

adam-urbanczyk commented Jan 15, 2023

Weird use case. If you can build a wheel, you can also build a conda package and install the deps from the env file. BTW: there is a PR in progress for arm64 OCP for the ocp-feedstock

If you really need pip, maybe this will work:

env -u CONDA_PREFIX_1 pip install ... 

@adam-urbanczyk adam-urbanczyk changed the title Cannot install in conda env anymore on an M1 mac How do I install cq in a conda env using pip Jan 15, 2023
@adam-urbanczyk adam-urbanczyk added the question Further information is requested label Jan 15, 2023
@bernhard-42
Copy link
Contributor Author

What do you mean with "weird use case". I and some others do have arm64 Macs and want to work with CadQuery. I don't see the weird part of this use case.

The wheel I built might have some issues (and I also had to create wheels for nlopt and casadi for arm64). While they do work with some simple tests, I don't want to publish them - and I have no clue about conda packaging. The approach up to the last commit was a good workaround until the OCP package exists.

And agreed, as soon as there is an OCP arm64 conda package it is a non issue any more. Nevertheless, until then a workaround is needed.

Maybe this is anyhow a good time to leave the conda ecosystem and move over to poetry ....

I'll give your suggestion a try tomorrow, thanks.

@jmwright
Copy link
Member

@bernhard-42 You can probably create your own local copy of the environment.yml file (and maybe the setup.py file too) which reverts the changes that were made in this commit. Then you can install the conda environment with conda env create -f environment_bernhard.yml -n cadquery. That should create a conda environment named cadquery that will be the same as it was before the change so you can use your custom wheel.

@adam-urbanczyk
Copy link
Member

What do you mean with "weird use case". I and some others do have arm64 Macs and want to work with CadQuery. I don't see the weird part of this use case.

"Weird" was about mixing package managers and not the platform itself. BTW both casadi and nlopt are avaiable on conda-forge for osx-arm64.

@bernhard-42
Copy link
Contributor Author

Got it, thanks @jmwright and @adam-urbanczyk

Not happy with mixing myself. However, I only had a private arm64 wheel for cadquery_ocp (otherwise I couldn't work with cadquery on my machine).
If I now choose the pip route, I don't find arm64 binaries for casadi and nlopt.
And if I go the conda route, I get casadi and nlopt, but no arm64 OCP.

And yes I could maintain my own environment.yml ...

Btw. what is the reason for preventing dependencies being installed via pip in a conda env. Usually, this will be controlled on the client side by ˋpip install --no-depsˋ and not prevented in the package, if I understand the python packaging approach correctly.

@bernhard-42
Copy link
Contributor Author

env -u CONDA_PREFIX_1 pip install git+https://github.com/cadquery/cadquery.git

works. But this is really looks a bit "weird" now ;-)

@adam-urbanczyk
Copy link
Member

See #1228 and pypa/pip#9948

@bernhard-42
Copy link
Contributor Author

makes sense, thanks

@adam-urbanczyk
Copy link
Member

@bernhard-42 would you be able to test this experimental OCP build https://anaconda.org/cctbx-dev/ocp with CQ on your arm64 mac?

See conda-forge/ocp-feedstock#23 for context.

@bernhard-42
Copy link
Contributor Author

Sure, will test it tomorrow and let you know

@bernhard-42
Copy link
Contributor Author

@adam-urbanczyk I tried to make some kind of end-to-end test with vtk 9.2.2 - seems to work:

image

@bernhard-42
Copy link
Contributor Author

For reference, the environment setup:

mamba create -n ocp-test python=3.8
mamba activate ocp-test
mamba install -c cctbx-dev ocp vtk pyvista panel jupyterlab

@adam-urbanczyk
Copy link
Member

Thanks @bernhard-42 ! You can use osx-arm64 ocp from conda-forge now.

@bernhard-42
Copy link
Contributor Author

Awesome! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants