Skip to content

Commit

Permalink
Merge pull request #745 from thewtex/jupyter-notebook-7
Browse files Browse the repository at this point in the history
jupyter notebook 7
  • Loading branch information
thewtex authored Apr 17, 2024
2 parents 5d83f28 + d9b4585 commit 2d051a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
34 changes: 19 additions & 15 deletions itkwidgets/integrations/environment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from enum import Enum
from importlib import import_module
from packaging import version
import importlib_metadata
import sys


Expand Down Expand Up @@ -28,7 +30,6 @@ def find_env():
else:
return Env.SAGEMAKER
except:
import sys
if sys.platform == 'emscripten':
return Env.JUPYTERLITE
return Env.HYPHA
Expand All @@ -38,22 +39,25 @@ def find_env():

if ENVIRONMENT is not Env.JUPYTERLITE and ENVIRONMENT is not Env.HYPHA:
if ENVIRONMENT is not Env.COLAB:
if ENVIRONMENT is Env.JUPYTER_NOTEBOOK and sys.version_info.minor > 7:
try:
import imjoy_jupyter_extension
except:
raise RuntimeError('imjoy-jupyter-extension is required. `pip install itkwidgets[notebook]` and refresh page.')
else:
if ENVIRONMENT is Env.JUPYTER_NOTEBOOK:
notebook_version = importlib_metadata.version('notebook')
if version.parse(notebook_version) < version.parse('7'):
raise RuntimeError('itkwidgets 1.0a51 and newer requires Jupyter notebook>=7.')
elif ENVIRONMENT is Env.JUPYTERLAB:
lab_version = importlib_metadata.version('jupyterlab')
if version.parse(lab_version) < version.parse('4'):
raise RuntimeError('itkwidgets 1.0a51 and newer requires jupyterlab>=4.')

try:
import_module("imjoy-jupyterlab-extension")
except ModuleNotFoundError:
try:
import_module("imjoy-jupyterlab-extension")
import_module("imjoy_jupyterlab_extension")
except ModuleNotFoundError:
try:
import_module("imjoy_jupyterlab_extension")
except ModuleNotFoundError:
if ENVIRONMENT is Env.JUPYTERLITE:
raise RuntimeError('imjoy-jupyterlab-extension is required. Install the package and refresh page.')
elif sys.version_info.minor > 7:
raise RuntimeError('imjoy-jupyterlab-extension is required. `pip install itkwidgets[lab]` and refresh page.')
if ENVIRONMENT is Env.JUPYTERLITE:
raise RuntimeError('imjoy-jupyterlab-extension is required. Install the package and refresh page.')
elif sys.version_info.minor > 7:
raise RuntimeError('imjoy-jupyterlab-extension is required. `pip install itkwidgets[lab]` and refresh page.')

try:
import imjoy_elfinder
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Source = "https://github.com/InsightSoftwareConsortium/itkwidgets"
all = [
"imjoy-jupyterlab-extension",
"imjoy-elfinder[jupyter]",
"imjoy-jupyter-extension",
"aiohttp <4.0"
]
lab = [
Expand All @@ -82,7 +81,7 @@ cli = [
]

notebook = [
"imjoy-jupyter-extension >=0.3.0",
"imjoy-jupyterlab-extension",
"imjoy-elfinder[jupyter]"
]
test = [
Expand Down

0 comments on commit 2d051a4

Please sign in to comment.