From bc6c147b7364707d496ad3f8c38e67266e7d147a Mon Sep 17 00:00:00 2001 From: Eivind Fonn Date: Tue, 13 Feb 2024 21:20:44 +0100 Subject: [PATCH] Fix splipy.io optional imports --- splipy/io/__init__.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/splipy/io/__init__.py b/splipy/io/__init__.py index 6aaad3c..9e44cca 100644 --- a/splipy/io/__init__.py +++ b/splipy/io/__init__.py @@ -4,27 +4,23 @@ from .stl import STL from .ofoam import OpenFOAM +__all__ = ['G2', 'SVG', 'SPL', 'STL', 'OpenFOAM'] from importlib.util import find_spec + + has_cv2 = find_spec('cv2') -has_rhino = find_spec('rhino3dm') # GRDECL depends on optional cv2 has_grdecl = has_cv2 -if has_cv2: - pass - - -# ThreeDM depends on optional rhino3dm -if has_rhino: - pass - - -__all__ = ['G2', 'SVG', 'SPL', 'STL', 'OpenFOAM'] - if has_grdecl: + from .grdecl import GRDECL __all__.append('GRDECL') + +# ThreeDM depends on optional rhino3dm +has_rhino = find_spec('rhino3dm') if has_rhino: + from .threedm import ThreeDM __all__.append('ThreeDM')