From 36734b78928a63920394874ced24a6ad312ee274 Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Mon, 22 Jan 2024 14:22:15 +0100 Subject: [PATCH] Fix: Added missing dependencies. Also add better warnings for missing dependencies. --- gustaf/show.py | 8 +++++++- gustaf/utils/notebook_helper.py | 7 +++++++ pyproject.toml | 6 +++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gustaf/show.py b/gustaf/show.py index 05abddda5..a7e980e7a 100644 --- a/gustaf/show.py +++ b/gustaf/show.py @@ -7,7 +7,13 @@ import numpy as np from gustaf import utils -from gustaf.utils.notebook_helper import K3DPlotterN + +try: + from gustaf.utils.notebook_helper import K3DPlotterN +except ImportError as err: + from gustaf.helpers.raise_if import ModuleImportRaiser + + K3DPlotterN = ModuleImportRaiser("IPython and ipywidgets", err) # @linux it raises error if vedo is imported inside the function. try: diff --git a/gustaf/utils/notebook_helper.py b/gustaf/utils/notebook_helper.py index bb2c4d041..bce869f5f 100644 --- a/gustaf/utils/notebook_helper.py +++ b/gustaf/utils/notebook_helper.py @@ -1,3 +1,5 @@ +import importlib + import numpy as np import vedo from IPython.display import display @@ -39,6 +41,11 @@ def get_shape(N, x, y): class K3DPlotterN(GridspecLayout): def __init__(self, N, size, background=0xFFFFFF): + if importlib.util.find_spec("k3d") is None: + raise ImportError( + "k3d is not installed. Please install it with `pip " + "install k3d`." + ) self.N = N self.x, self.y = get_shape(N, *(2160, 1440)) self.shape = (self.x, self.y) diff --git a/pyproject.toml b/pyproject.toml index e95132112..dc8876cb5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,9 @@ all = [ "meshio", "napf>=0.0.5", "funi>=0.0.1", - "requests" + "requests", + "ipywidgets", + "k3d", ] test = [ "pytest", @@ -57,6 +59,8 @@ dev = [ "meshio", "requests", "pre-commit", + "ipywidgets", + "k3d", ] [tool.setuptools]