1
1
from enum import Enum
2
2
from importlib import import_module
3
+ from packaging import version
4
+ import importlib_metadata
3
5
import sys
4
6
5
7
@@ -28,7 +30,6 @@ def find_env():
28
30
else :
29
31
return Env .SAGEMAKER
30
32
except :
31
- import sys
32
33
if sys .platform == 'emscripten' :
33
34
return Env .JUPYTERLITE
34
35
return Env .HYPHA
@@ -38,22 +39,25 @@ def find_env():
38
39
39
40
if ENVIRONMENT is not Env .JUPYTERLITE and ENVIRONMENT is not Env .HYPHA :
40
41
if ENVIRONMENT is not Env .COLAB :
41
- if ENVIRONMENT is Env .JUPYTER_NOTEBOOK and sys .version_info .minor > 7 :
42
- try :
43
- import imjoy_jupyter_extension
44
- except :
45
- raise RuntimeError ('imjoy-jupyter-extension is required. `pip install itkwidgets[notebook]` and refresh page.' )
46
- else :
42
+ if ENVIRONMENT is Env .JUPYTER_NOTEBOOK :
43
+ notebook_version = importlib_metadata .version ('notebook' )
44
+ if version .parse (notebook_version ) < version .parse ('7' ):
45
+ raise RuntimeError ('itkwidgets 1.0a51 and newer requires Jupyter notebook>=7.' )
46
+ elif ENVIRONMENT is Env .JUPYTERLAB :
47
+ lab_version = importlib_metadata .version ('jupyterlab' )
48
+ if version .parse (lab_version ) < version .parse ('4' ):
49
+ raise RuntimeError ('itkwidgets 1.0a51 and newer requires jupyterlab>=4.' )
50
+
51
+ try :
52
+ import_module ("imjoy-jupyterlab-extension" )
53
+ except ModuleNotFoundError :
47
54
try :
48
- import_module ("imjoy-jupyterlab-extension " )
55
+ import_module ("imjoy_jupyterlab_extension " )
49
56
except ModuleNotFoundError :
50
- try :
51
- import_module ("imjoy_jupyterlab_extension" )
52
- except ModuleNotFoundError :
53
- if ENVIRONMENT is Env .JUPYTERLITE :
54
- raise RuntimeError ('imjoy-jupyterlab-extension is required. Install the package and refresh page.' )
55
- elif sys .version_info .minor > 7 :
56
- raise RuntimeError ('imjoy-jupyterlab-extension is required. `pip install itkwidgets[lab]` and refresh page.' )
57
+ if ENVIRONMENT is Env .JUPYTERLITE :
58
+ raise RuntimeError ('imjoy-jupyterlab-extension is required. Install the package and refresh page.' )
59
+ elif sys .version_info .minor > 7 :
60
+ raise RuntimeError ('imjoy-jupyterlab-extension is required. `pip install itkwidgets[lab]` and refresh page.' )
57
61
58
62
try :
59
63
import imjoy_elfinder
0 commit comments