Skip to content

Commit 5e9f076

Browse files
committed
Make vtk optional
1 parent 0bfb926 commit 5e9f076

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

ipygany/ipygany.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313
DOMWidget, Widget,
1414
Color
1515
)
16-
import vtk
1716

1817
from .serialization import array_serialization, component_array_serialization
19-
from .vtk_loader import (
20-
load_vtk, FLOAT32, UINT32,
21-
get_ugrid_vertices, get_ugrid_triangles, get_ugrid_tetrahedrons, get_ugrid_data
22-
)
2318

2419
from ._frontend import module_version, module_name
2520

21+
FLOAT32 = 'f'
22+
UINT32 = 'I'
23+
2624

2725
class _GanyWidgetBase(Widget):
2826
_model_module = Unicode(module_name).tag(sync=True)
@@ -167,6 +165,13 @@ def from_vtk(path, **kwargs):
167165
path : str or vtk.vtkUnstructuredGrid
168166
The path to the VTK file or an unstructured grid in memory.
169167
"""
168+
import vtk
169+
170+
from .vtk_loader import (
171+
load_vtk,
172+
get_ugrid_vertices, get_ugrid_triangles, get_ugrid_data
173+
)
174+
170175
if isinstance(path, str):
171176
grid = load_vtk(path)
172177
elif isinstance(path, vtk.vtkUnstructuredGrid):
@@ -186,6 +191,10 @@ def from_vtk(path, **kwargs):
186191

187192
def reload(self, path, reload_vertices=False, reload_triangles=False, reload_data=True):
188193
"""Reload a vtk file, entirely or partially."""
194+
from .vtk_loader import (
195+
load_vtk, get_ugrid_vertices, get_ugrid_triangles, get_ugrid_data
196+
)
197+
189198
grid = load_vtk(path)
190199

191200
with self.hold_sync():
@@ -249,6 +258,12 @@ def from_vtk(path, **kwargs):
249258
path : str or vtk.vtkUnstructuredGrid
250259
The path to the VTK file or an unstructured grid in memory.
251260
"""
261+
import vtk
262+
263+
from .vtk_loader import (
264+
load_vtk, get_ugrid_vertices, get_ugrid_triangles, get_ugrid_tetrahedrons, get_ugrid_data
265+
)
266+
252267
if isinstance(path, str):
253268
grid = load_vtk(path)
254269
elif isinstance(path, vtk.vtkUnstructuredGrid):
@@ -269,6 +284,10 @@ def from_vtk(path, **kwargs):
269284

270285
def reload(self, path, reload_vertices=False, reload_triangles=False, reload_data=True, reload_tetrahedrons=False):
271286
"""Reload a vtk file, entirely or partially."""
287+
from .vtk_loader import (
288+
load_vtk, get_ugrid_vertices, get_ugrid_triangles, get_ugrid_tetrahedrons, get_ugrid_data
289+
)
290+
272291
grid = load_vtk(path)
273292

274293
with self.hold_sync():

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@
8989
install_requires = [
9090
'ipywidgets>=7.0.0',
9191
'traittypes',
92-
'numpy',
93-
'vtk',
92+
'numpy'
9493
],
9594
extras_require = {
9695
'test': [
@@ -99,7 +98,7 @@
9998
'nbval',
10099
],
101100
'examples': [
102-
# Any requirements for the examples to run
101+
'vtk'
103102
],
104103
'docs': [
105104
'sphinx>=1.5',

0 commit comments

Comments
 (0)