Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jupyter notebook 7 #745

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading