-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Support the no-VTK OCP modules for testing cadquery_ocp_novtk #880
Comments
This approach would be even better: diff --git a/src/build123d/topology/shape_core.py b/src/build123d/topology/shape_core.py
index 7ebeaae..feda338 100644
--- a/src/build123d/topology/shape_core.py
+++ b/src/build123d/topology/shape_core.py
@@ -104,8 +104,13 @@ from OCP.GProp import GProp_GProps
from OCP.Geom import Geom_Line
from OCP.GeomAPI import GeomAPI_ProjectPointOnSurf
from OCP.GeomLib import GeomLib_IsPlanarSurface
-from OCP.IVtkOCC import IVtkOCC_Shape, IVtkOCC_ShapeMesher
-from OCP.IVtkVTK import IVtkVTK_ShapeData
+try:
+ from OCP.IVtkOCC import IVtkOCC_Shape, IVtkOCC_ShapeMesher
+ from OCP.IVtkVTK import IVtkVTK_ShapeData
+ from vtkmodules.vtkCommonDataModel import vtkPolyData
+ from vtkmodules.vtkFiltersCore import vtkPolyDataNormals, vtkTriangleFilter
+except:
+ warnings.warn("No VTK support")
from OCP.Prs3d import Prs3d_IsoAspect
from OCP.Quantity import Quantity_Color
from OCP.ShapeAnalysis import ShapeAnalysis_Curve
@@ -152,9 +157,6 @@ from build123d.geometry import (
from typing_extensions import Self
from typing import Literal
-from vtkmodules.vtkCommonDataModel import vtkPolyData
-from vtkmodules.vtkFiltersCore import vtkPolyDataNormals, vtkTriangleFilter
-
if TYPE_CHECKING: # pragma: no cover
from .zero_d import Vertex # pylint: disable=R0801 |
This is not meant to be used by users of build123d and should not be documented (at the end, it is not straightforward to install build123d without VTK). |
I support this idea. |
looks like the VTK stuff is only used in try:
from OCP.IVtkOCC import IVtkOCC_Shape, IVtkOCC_ShapeMesher
from OCP.IVtkVTK import IVtkVTK_ShapeData
from vtkmodules.vtkCommonDataModel import vtkPolyData
from vtkmodules.vtkFiltersCore import vtkPolyDataNormals, vtkTriangleFilter
except ImportError:
pass # don't warn for now def to_vtk_poly_data(self, ...):
try:
... # original VTK stuff
except NameError:
raise ImportError("optional VTK modules are required") # or something? edit: actually it's also used in |
@snoyer My idea was to change the absolute minimum that allows to run the tests. The proposed |
@bernhard-42 I understand what you're trying to do and I understand that it would not be such a big deal to skip the failing import and let the VTK methods crash on call (because the import would nominally/hopefully not be missing for real users). However that's still asking As mentioned in my edit the changes would not be as minimal as I thought so it's possibly not worth doing more that what you suggest. (the real proper way to do it would be to refactor and only import VTK when needed in Jupyter/IPython contexts instead of baking it into the shape class, but that's another discussion) |
I prefer to solve this by moving the vtk functionality out of |
I created a pull request #887 that moves all VTK code to |
ocp-build-system creates a no-VTK version
cadquery_ocp_novtk
.To test it I use a patched
build123d
Would it be possible to add the following change:
There would be no change in build123d behaviour when
NOVTK
isn't set, which is the default on every machine.However, I could set it in my github action for the test:
The text was updated successfully, but these errors were encountered: