Skip to content

cq-editor: init at 0.6.2#486070

Open
cjshearer wants to merge 12 commits intoNixOS:masterfrom
cjshearer:feat/add-cadquery
Open

cq-editor: init at 0.6.2#486070
cjshearer wants to merge 12 commits intoNixOS:masterfrom
cjshearer:feat/add-cadquery

Conversation

@cjshearer
Copy link
Member

Adds cq-editor, cadquery, and their dependencies.

The latest attempt for some of these dependencies (notably cadquery/cadquery-ocp) stalled in this PR.

Note that while previous packagers (including myself) attempted to codegen the OCP python bindings, I have chosen here to take the simpler and more reliable approach of using the python bindings from the GitHub releases for OCP (which we then build).

I recognize that this approach does not cover darwin, but I do not have a Mac to test on anyway. If someone would like to add Mac support, I would encourage them to try, but suggest that this should be done in a follow-up PR; this PR is massive as-is.

If someone else with experience packaging this (@tnytown, @vincentbernat, @marcus7070) would like to jump in as a maintainer for these, please feel free!

Also tagging previous reviewers: @Sigmanificient, @qbisi.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@nixpkgs-ci nixpkgs-ci bot requested a review from natsukium February 1, 2026 22:50
@nixpkgs-ci nixpkgs-ci bot added 8.has: package (new) This PR adds a new package 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 6.topic: python Python is a high-level, general-purpose programming language. labels Feb 1, 2026
@qbisi
Copy link
Contributor

qbisi commented Feb 1, 2026

Hi @cjshearer, can you use the trame feature of cadquery in jupyter notebook, and check if we need this patch for trame/trame-client: https://github.com/qbisi/nur-fem/blob/master/pkgs/python-by-name/trame/copytree-writable.patch.

@cjshearer
Copy link
Member Author

@qbisi I haven't used a jupyter notebook in a long time, especially not on nixpkgs - is there some kind of existing example you could refer me to, so that I can test that?

Also, do you think that would that require packaging trame-jupyter-extension as well? If so, I'd be worried about scope-creep; my goal wasn't to make each dependency work for everything, but to get a modern cadquery/cq-editor version back in nixpkgs.

@qbisi
Copy link
Contributor

qbisi commented Feb 1, 2026

Maybe this one: CadQuery/cadquery#1786

@cjshearer
Copy link
Member Author

cjshearer commented Feb 1, 2026

Maybe this one: CadQuery/cadquery#1786

Oh, I understand now! Yeah, I tested that.

Test script
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=. -i "python3 -I" -p "python3.withPackages(p: with p; [ cadquery ])"
from cadquery.fig import Figure
from cadquery.func import sphere, torus
from time import sleep

# this starts a server and opens a browser tab
fig = Figure()

sleep(5)

# we can use show, the API is fluent
fig.show(torus(10, 2), color='violet').show(sphere(5))

sleep(5)

# zoom to fit
fig.fit()

sleep(5)

# clear
fig.clear()

sleep(5)
image

@qbisi
Copy link
Contributor

qbisi commented Feb 2, 2026

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 486070 -p python313Packages.trame-vuetify
Commit: a89257ed288786079fc15e6c7eb1d5927fb09cd9 (subsequent changes)
Merge: 4d3e2445581c5106ca672c5d684066f5d2fa928e

Logs: https://github.com/qbisi/nixpkgs-review-gha/actions/runs/21590449066


x86_64-linux

❌ 2 packages failed to build:
  • python313Packages.trame-vuetify
  • python313Packages.trame-vuetify.dist (python313Packages.trame-vuetify.dist.dist)

aarch64-linux

❌ 2 packages failed to build:
  • python313Packages.trame-vuetify
  • python313Packages.trame-vuetify.dist (python313Packages.trame-vuetify.dist.dist)

@qbisi
Copy link
Contributor

qbisi commented Feb 2, 2026

@cjshearer with #442540, we can create a python venv with some system python packages from nixpkgs while others from pypi.

The key to use cq-editor is to package the hard c dep cadquery-ocp in nixpkgs, while we can install other pure python/javascript pacakges from pypi. Maintaing trame* packages can be painfull jobs as these projects are managed/published by npm's semantic-release which is unfriendly to linux distro maintainers. But i am not against that you take the responsibility to package all these depdenencies cq-editor need in nixpkgs.

…from pypi

These dependencies contain pure python and js, so
we can avoid the complexity of packing them from
git without patching any binaries.
@qbisi
Copy link
Contributor

qbisi commented Feb 8, 2026

It's time to go cadquery-ocp-7.9.3.0 directly with #486359

@cjshearer
Copy link
Member Author

cjshearer commented Feb 8, 2026

Ah, that's why cadquery-ocp failed after rebasing on master 😆. I'll get right on that.

@cjshearer
Copy link
Member Author

cjshearer commented Feb 8, 2026

@qbisi, #486359 is actually somewhat of a problem - upstream cadquery still depends on ocp 7.8.1. Just like the AUR package, this would put us ahead of upstream (cadquery PR for OCP 7.9), causing cadquery to fail during import:

Details
Executing pythonImportsCheckPhase
Check whether the following modules can be imported: cadquery
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import sys; import importlib; list(map(lambda mod: importlib.import_module(mod), sys.argv[1:]))
                                  ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <lambda>
    import sys; import importlib; list(map(lambda mod: importlib.import_module(mod), sys.argv[1:]))
                                                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/nix/store/slhpx9glq7vl99bwi93bgrhn3syv98s1-python3-3.13.11/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1023, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/nix/store/c9a9nfvg92z13qji291byqsli4nx7y00-python3.13-cadquery-2.6.1/lib/python3.13/site-packages/cadquery/__init__.py", line 11, in <module>
    from .occ_impl.shapes import (
    ...<9 lines>...
    )
  File "/nix/store/c9a9nfvg92z13qji291byqsli4nx7y00-python3.13-cadquery-2.6.1/lib/python3.13/site-packages/cadquery/occ_impl/shapes.py", line 359, in <module>
    ta.TopAbs_VERTEX: TopoDS.Vertex_s,
                      ^^^^^^^^^^^^^^^
AttributeError: module 'OCP.TopoDS.TopoDS' has no attribute 'Vertex_s'. Did you mean: 'Vertex'?
building '/nix/store/b48hpx9hcg999bnpfj0v3wcyan3nls9x-python3-3.13.11-env.drv'...
created 966 symlinks in user environment
Traceback (most recent call last):
  File "/home/cjshearer/repos/nixpkgs/./pkgs/development/python-modules/cadquery/test.py", line 12, in <module>
    from cadquery.fig import Figure
  File "/nix/store/9xik2vvx6bl2byw7gcs89gsbd07sh092-python3-3.13.11-env/lib/python3.13/site-packages/cadquery/__init__.py", line 11, in <module>
    from .occ_impl.shapes import (
    ...<9 lines>...
    )
  File "/nix/store/9xik2vvx6bl2byw7gcs89gsbd07sh092-python3-3.13.11-env/lib/python3.13/site-packages/cadquery/occ_impl/shapes.py", line 359, in <module>
    ta.TopAbs_VERTEX: TopoDS.Vertex_s,
                      ^^^^^^^^^^^^^^^
AttributeError: module 'OCP.TopoDS.TopoDS' has no attribute 'Vertex_s'. Did you mean: 'Vertex'?
I'll have to override opencascade's version in cadquery-ocp and stick with 7.8.1.2.

@qbisi
Copy link
Contributor

qbisi commented Feb 8, 2026

Maybe we can wait for CadQuery/cadquery#1968. I would also prefer generating cadquery-ocp source with pywrap based on opencascad-occt 7.9.3 like @tnytown's work in #433247. Vtk/opencascade-occt (Not vtk-full) in nixpkgs does not neccessary have mpi related symbol, it's better we dump the symbol and generate source from vtk/opencascade-occt in nixpkgs.
The recipe will be much cleaner after we bump opencascade-occt to 7.9.3.
I will open a draft pr relating cadquery-ocp later.

@tnytown
Copy link
Contributor

tnytown commented Feb 9, 2026

Hi, good to see work on this constellation of packages progressing! Let me know if any help is needed with cadquery-ocp; I have some local work that I'll tidy up and push.

@tnytown
Copy link
Contributor

tnytown commented Feb 10, 2026

The tip at #433247 has a working cadquery-ocp, although there are failing tests there that need to be investigated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants