Skip to content

Commit

Permalink
Decrease imports reach on wheel build.
Browse files Browse the repository at this point in the history
Moving _is_debugpy_available to .debugger to avoid having import that
much of the package on wheel building. In particular this was forcing
`psutil`  to be importable to build this package
  • Loading branch information
Carreau committed Feb 21, 2022
1 parent 16807bf commit 5c16fde
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
12 changes: 8 additions & 4 deletions ipykernel/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@

from .compiler import (get_file_name, get_tmp_directory, get_tmp_hash_seed)

# This import is required to have the next ones working...
from debugpy.server import api # noqa
from _pydevd_bundle import pydevd_frame_utils
from _pydevd_bundle.pydevd_suspended_frames import SuspendedFramesManager, _FramesTracker
try:
# This import is required to have the next ones working...
from debugpy.server import api # noqa
from _pydevd_bundle import pydevd_frame_utils
from _pydevd_bundle.pydevd_suspended_frames import SuspendedFramesManager, _FramesTracker
_is_debugpy_available = True
except ImportError:
_is_debugpy_available = False

# Required for backwards compatiblity
ROUTING_ID = getattr(zmq, 'ROUTING_ID', None) or zmq.IDENTITY
Expand Down
7 changes: 1 addition & 6 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .zmqshell import ZMQInteractiveShell
from .eventloops import _use_appnope
from .compiler import XCachingCompiler
from .debugger import Debugger, _is_debugpy_available

try:
from IPython.core.interactiveshell import _asyncio_runner
Expand All @@ -33,12 +34,6 @@
except ImportError:
_use_experimental_60_completion = False

try:
import debugpy
from .debugger import Debugger
_is_debugpy_available = True
except ImportError:
_is_debugpy_available = False

_EXPERIMENTAL_KEY_NAME = '_jupyter_types_experimental'

Expand Down
2 changes: 1 addition & 1 deletion ipykernel/kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from jupyter_client.kernelspec import KernelSpecManager

from .ipkernel import _is_debugpy_available
from .debugger import _is_debugpy_available

pjoin = os.path.join

Expand Down

0 comments on commit 5c16fde

Please sign in to comment.