forked from jupyter-widgets/ipywidgets
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport PR jupyter-widgets#3811: Replace ipykernel dependency by the…
… comm dependency
- Loading branch information
1 parent
5acbc62
commit b02d083
Showing
6 changed files
with
42 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# compatibility shim for ipykernel < 6.18 | ||
import sys | ||
from IPython import get_ipython | ||
import comm | ||
|
||
|
||
def requires_ipykernel_shim(): | ||
if "ipykernel" in sys.modules: | ||
import ipykernel | ||
|
||
version = ipykernel.version_info | ||
return version < (6, 18) | ||
else: | ||
return False | ||
|
||
|
||
def get_comm_manager(): | ||
if requires_ipykernel_shim(): | ||
ip = get_ipython() | ||
|
||
if ip is not None and getattr(ip, "kernel", None) is not None: | ||
return get_ipython().kernel.comm_manager | ||
else: | ||
return comm.get_comm_manager() | ||
|
||
|
||
def create_comm(*args, **kwargs): | ||
if requires_ipykernel_shim(): | ||
from ipykernel.comm import Comm | ||
|
||
return Comm(*args, **kwargs) | ||
else: | ||
return comm.create_comm(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters