diff --git a/src/pyhpp_plot/__init__.py b/src/pyhpp_plot/__init__.py index 67b95f1..0ae0f11 100644 --- a/src/pyhpp_plot/__init__.py +++ b/src/pyhpp_plot/__init__.py @@ -1,9 +1,3 @@ -from .graph_viewer import ( - MenuActionProxy, - show_graph, - show_graph_blocking, - show_interactive_graph, -) from .graph_viewer_thread import GraphViewerThread from .interactive_viewer import InteractiveGraphViewer from .websocket_bridge import GraphWebSocketBridge @@ -12,8 +6,26 @@ "GraphViewerThread", "GraphWebSocketBridge", "InteractiveGraphViewer", - "MenuActionProxy", - "show_graph", - "show_graph_blocking", - "show_interactive_graph", ] + +try: + # `graph_viewer` is a Boost.Python extension module built only when + # hpp-plot is compiled with -DUSE_QT=ON (see CMakeLists.txt). It is not + # required by the recommended pyhpp_plot workflow (GraphViewerThread / + # InteractiveGraphViewer / GraphWebSocketBridge), so its absence must not + # prevent `import pyhpp_plot` from succeeding when built with USE_QT=OFF. + from .graph_viewer import ( + MenuActionProxy, + show_graph, + show_graph_blocking, + show_interactive_graph, + ) + + __all__ += [ + "MenuActionProxy", + "show_graph", + "show_graph_blocking", + "show_interactive_graph", + ] +except ImportError: + pass