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

Replace ipykernel dependency by the comm dependency #3811

Merged
merged 4 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/workflows/devinstall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Install dependencies
run: |
python -m pip install notebook jupyterlab jupyter_packaging~=0.10
python -m pip install notebook jupyterlab notebook~=6.0 jupyter_packaging~=0.10
- name: Run the dev-install script
run: |
./dev-install.sh
Expand Down
6 changes: 3 additions & 3 deletions dev-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jlpm build
echo -n "widgetsnbextension"
pip install -v -e ./python/widgetsnbextension
if [[ "$OSTYPE" == "msys" ]]; then
jupyter nbextension install --overwrite --py $nbExtFlags widgetsnbextension
jupyter nbextension install --overwrite --py $nbExtFlags widgetsnbextension || true
else
jupyter nbextension install --overwrite --py --symlink $nbExtFlags widgetsnbextension
jupyter nbextension install --overwrite --py --symlink $nbExtFlags widgetsnbextension || true
fi
jupyter nbextension enable --py $nbExtFlags widgetsnbextension
jupyter nbextension enable --py $nbExtFlags widgetsnbextension || true

echo -n "ipywidgets"
pip install -v -e "./python/ipywidgets[test]"
Expand Down
8 changes: 6 additions & 2 deletions docs/source/examples/Widget Custom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{
"cell_type": "markdown",
"metadata": {
"tags": ["remove-cell"]
"tags": [
"remove-cell"
]
},
"source": [
"[Index](Index.ipynb) - [Back](Widget%20Styling.ipynb) - [Next](Widget%20Asynchronous.ipynb)"
Expand Down Expand Up @@ -828,7 +830,9 @@
{
"cell_type": "markdown",
"metadata": {
"tags": ["remove-cell"]
"tags": [
"remove-cell"
]
},
"source": [
"[Index](Index.ipynb) - [Back](Widget%20Styling.ipynb) - [Next](Widget%20Asynchronous.ipynb)"
Expand Down
10 changes: 7 additions & 3 deletions python/ipywidgets/ipywidgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@
from ._version import __version__, __protocol_version__, __jupyter_widgets_controls_version__, __jupyter_widgets_base_version__

import os
import sys

from traitlets import link, dlink
from IPython import get_ipython
try:
from comm import get_comm_manager
except ImportError:

# ipykernel <6.18 when the comm package did not exist
if "ipykernel" in sys.modules and "comm" not in sys.modules:
def get_comm_manager():
ip = get_ipython()

if ip is not None and getattr(ip, "kernel", None) is not None:
return get_ipython().kernel.comm_manager
# Using the comm package
else:
from comm import get_comm_manager

from .widgets import *

Expand Down
3 changes: 0 additions & 3 deletions python/ipywidgets/ipywidgets/tests/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

import traitlets

# This has a byproduct of setting up the comms
import ipykernel.ipkernel

from ..widgets import IntSlider, IntText, Text, Widget, jslink, HBox, widget_serialization, widget as widget_module
from ..embed import embed_data, embed_snippet, embed_minimal_html, dependency_state

Expand Down
8 changes: 5 additions & 3 deletions python/ipywidgets/ipywidgets/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
in the Jupyter notebook front-end.
"""
import os
import sys
import typing
from contextlib import contextmanager
from collections.abc import Iterable
Expand Down Expand Up @@ -524,13 +525,14 @@ def open(self):
if self._model_id is not None:
args['comm_id'] = self._model_id

try:
from comm import create_comm
except ImportError:
# ipykernel <6.18 when the comm package did not exist
if "ipykernel" in sys.modules and "comm" not in sys.modules:
def create_comm(**kwargs):
from ipykernel.comm import Comm

return Comm(**kwargs)
else:
from comm import create_comm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


self.comm = create_comm(**args)

Expand Down
2 changes: 1 addition & 1 deletion python/ipywidgets/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ zip_safe = False
packages = find:

install_requires =
ipykernel>=4.5.1
comm>=0.1.3
ipython>=6.1.0
traitlets>=4.3.1
widgetsnbextension~=4.0.7
Expand Down