From 16fd1e32e89a94930ed4e92e006cbf594bfe7819 2015-03-28 00:46:25 From: Min RK Date: 2015-03-28 00:46:25 Subject: [PATCH] remove ipython_kernel.zmq sub-pkg --- diff --git a/IPython/kernel/__init__.py b/IPython/kernel/__init__.py index 52f736e..33c6ef2 100644 --- a/IPython/kernel/__init__.py +++ b/IPython/kernel/__init__.py @@ -13,16 +13,18 @@ warn("The `IPython.kernel` package has been deprecated. " from IPython.utils.shimmodule import ShimModule -# session moved relative to top-level +# zmq subdir is gone sys.modules['IPython.kernel.zmq.session'] = ShimModule('session', mirror='jupyter_client.session') +sys.modules['IPython.kernel.zmq'] = ShimModule('zmq', mirror='ipython_kernel') -for pkg in ('comm', 'inprocess', 'resources', 'zmq'): +for pkg in ('comm', 'inprocess', 'resources'): sys.modules['IPython.kernel.%s' % pkg] = ShimModule(pkg, mirror='ipython_kernel.%s' % pkg) + for pkg in ('ioloop', 'blocking'): sys.modules['IPython.kernel.%s' % pkg] = ShimModule(pkg, mirror='jupyter_client.%s' % pkg) # required for `from IPython.kernel import PKG` -from ipython_kernel import comm, inprocess, resources, zmq +from ipython_kernel import comm, inprocess, resources from jupyter_client import ioloop, blocking # public API from ipython_kernel.connect import * diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 3a679d0..d84fab5 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -232,10 +232,10 @@ sec.requires('zmq') # The in-process kernel tests are done in a separate section sec.exclude('inprocess') # importing gtk sets the default encoding, which we want to avoid -sec.exclude('zmq.gui.gtkembed') -sec.exclude('zmq.gui.gtk3embed') +sec.exclude('gui.gtkembed') +sec.exclude('gui.gtk3embed') if not have['matplotlib']: - sec.exclude('zmq.pylab') + sec.exclude('pylab') # kernel.inprocess: test_sections['kernel.inprocess'].requires('zmq') diff --git a/ipython_kernel/__main__.py b/ipython_kernel/__main__.py index 93d8472..4b8d4ef 100644 --- a/ipython_kernel/__main__.py +++ b/ipython_kernel/__main__.py @@ -1,3 +1,3 @@ if __name__ == '__main__': - from ipython_kernel.zmq import kernelapp as app + from ipython_kernel import kernelapp as app app.launch_new_instance() diff --git a/ipython_kernel/comm/comm.py b/ipython_kernel/comm/comm.py index 6619bd6..ca9685c 100644 --- a/ipython_kernel/comm/comm.py +++ b/ipython_kernel/comm/comm.py @@ -9,7 +9,7 @@ import uuid from zmq.eventloop.ioloop import IOLoop from IPython.config import LoggingConfigurable -from ipython_kernel.zmq.kernelbase import Kernel +from ipython_kernel.kernelbase import Kernel from IPython.utils.jsonutil import json_clean from IPython.utils.traitlets import Instance, Unicode, Bytes, Bool, Dict, Any @@ -20,7 +20,7 @@ class Comm(LoggingConfigurable): # If this is instantiated by a non-IPython kernel, shell will be None shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) - kernel = Instance('ipython_kernel.zmq.kernelbase.Kernel') + kernel = Instance('ipython_kernel.kernelbase.Kernel') def _kernel_default(self): if Kernel.initialized(): return Kernel.instance() @@ -28,7 +28,7 @@ class Comm(LoggingConfigurable): iopub_socket = Any() def _iopub_socket_default(self): return self.kernel.iopub_socket - session = Instance('ipython_kernel.zmq.session.Session') + session = Instance('ipython_kernel.session.Session') def _session_default(self): if self.kernel is not None: return self.kernel.session diff --git a/ipython_kernel/comm/manager.py b/ipython_kernel/comm/manager.py index 066416c..acba849 100644 --- a/ipython_kernel/comm/manager.py +++ b/ipython_kernel/comm/manager.py @@ -31,12 +31,12 @@ class CommManager(LoggingConfigurable): # If this is instantiated by a non-IPython kernel, shell will be None shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) - kernel = Instance('ipython_kernel.zmq.kernelbase.Kernel') + kernel = Instance('ipython_kernel.kernelbase.Kernel') iopub_socket = Any() def _iopub_socket_default(self): return self.kernel.iopub_socket - session = Instance('ipython_kernel.zmq.session.Session') + session = Instance('ipython_kernel.session.Session') def _session_default(self): return self.kernel.session diff --git a/ipython_kernel/zmq/datapub.py b/ipython_kernel/datapub.py similarity index 94% rename from ipython_kernel/zmq/datapub.py rename to ipython_kernel/datapub.py index 40d76a1..08af380 100644 --- a/ipython_kernel/zmq/datapub.py +++ b/ipython_kernel/datapub.py @@ -16,8 +16,8 @@ from IPython.config import Configurable from ipython_kernel.inprocess.socket import SocketABC from IPython.utils.jsonutil import json_clean from IPython.utils.traitlets import Instance, Dict, CBytes -from ipython_kernel.zmq.serialize import serialize_object -from ipython_kernel.zmq.session import Session, extract_header +from ipython_kernel.serialize import serialize_object +from ipython_kernel.session import Session, extract_header #----------------------------------------------------------------------------- # Code @@ -66,5 +66,5 @@ def publish_data(data): data : dict The data to be published. Think of it as a namespace. """ - from ipython_kernel.zmq.zmqshell import ZMQInteractiveShell + from ipython_kernel.zmqshell import ZMQInteractiveShell ZMQInteractiveShell.instance().data_pub.publish_data(data) diff --git a/ipython_kernel/zmq/displayhook.py b/ipython_kernel/displayhook.py similarity index 100% rename from ipython_kernel/zmq/displayhook.py rename to ipython_kernel/displayhook.py diff --git a/ipython_kernel/zmq/embed.py b/ipython_kernel/embed.py similarity index 100% rename from ipython_kernel/zmq/embed.py rename to ipython_kernel/embed.py diff --git a/ipython_kernel/zmq/eventloops.py b/ipython_kernel/eventloops.py similarity index 99% rename from ipython_kernel/zmq/eventloops.py rename to ipython_kernel/eventloops.py index 11b186d..25ba87c 100644 --- a/ipython_kernel/zmq/eventloops.py +++ b/ipython_kernel/eventloops.py @@ -49,7 +49,7 @@ def register_integration(*toolkitnames): instance, arrange for the event loop to call ``kernel.do_one_iteration()`` at least every ``kernel._poll_interval`` seconds, and start the event loop. - :mod:`ipython_kernel.zmq.eventloops` provides and registers such functions + :mod:`ipython_kernel.eventloops` provides and registers such functions for a few common event loops. """ def decorator(func): diff --git a/ipython_kernel/zmq/gui/__init__.py b/ipython_kernel/gui/__init__.py similarity index 100% rename from ipython_kernel/zmq/gui/__init__.py rename to ipython_kernel/gui/__init__.py diff --git a/ipython_kernel/zmq/gui/gtk3embed.py b/ipython_kernel/gui/gtk3embed.py similarity index 100% rename from ipython_kernel/zmq/gui/gtk3embed.py rename to ipython_kernel/gui/gtk3embed.py diff --git a/ipython_kernel/zmq/gui/gtkembed.py b/ipython_kernel/gui/gtkembed.py similarity index 100% rename from ipython_kernel/zmq/gui/gtkembed.py rename to ipython_kernel/gui/gtkembed.py diff --git a/ipython_kernel/zmq/heartbeat.py b/ipython_kernel/heartbeat.py similarity index 100% rename from ipython_kernel/zmq/heartbeat.py rename to ipython_kernel/heartbeat.py diff --git a/ipython_kernel/inprocess/ipkernel.py b/ipython_kernel/inprocess/ipkernel.py index d43e2d4..fcfbe52 100644 --- a/ipython_kernel/inprocess/ipkernel.py +++ b/ipython_kernel/inprocess/ipkernel.py @@ -10,8 +10,8 @@ import sys from IPython.core.interactiveshell import InteractiveShellABC from IPython.utils.jsonutil import json_clean from IPython.utils.traitlets import Any, Enum, Instance, List, Type -from ipython_kernel.zmq.ipkernel import IPythonKernel -from ipython_kernel.zmq.zmqshell import ZMQInteractiveShell +from ipython_kernel.ipkernel import IPythonKernel +from ipython_kernel.zmqshell import ZMQInteractiveShell from .socket import DummySocket @@ -121,18 +121,18 @@ class InProcessKernel(IPythonKernel): return logging.getLogger(__name__) def _session_default(self): - from ipython_kernel.zmq.session import Session + from ipython_kernel.session import Session return Session(parent=self, key=b'') def _shell_class_default(self): return InProcessInteractiveShell def _stdout_default(self): - from ipython_kernel.zmq.iostream import OutStream + from ipython_kernel.iostream import OutStream return OutStream(self.session, self.iopub_socket, u'stdout', pipe=False) def _stderr_default(self): - from ipython_kernel.zmq.iostream import OutStream + from ipython_kernel.iostream import OutStream return OutStream(self.session, self.iopub_socket, u'stderr', pipe=False) #----------------------------------------------------------------------------- @@ -150,7 +150,7 @@ class InProcessInteractiveShell(ZMQInteractiveShell): def enable_gui(self, gui=None): """Enable GUI integration for the kernel.""" - from ipython_kernel.zmq.eventloops import enable_gui + from ipython_kernel.eventloops import enable_gui if not gui: gui = self.kernel.gui return enable_gui(gui, kernel=self.kernel) diff --git a/ipython_kernel/zmq/iostream.py b/ipython_kernel/iostream.py similarity index 100% rename from ipython_kernel/zmq/iostream.py rename to ipython_kernel/iostream.py diff --git a/ipython_kernel/zmq/ipkernel.py b/ipython_kernel/ipkernel.py similarity index 98% rename from ipython_kernel/zmq/ipkernel.py rename to ipython_kernel/ipkernel.py index 39cf40e..1d31d11 100644 --- a/ipython_kernel/zmq/ipkernel.py +++ b/ipython_kernel/ipkernel.py @@ -10,7 +10,7 @@ from IPython.utils.tokenutil import token_at_cursor, line_at_cursor from IPython.utils.traitlets import Instance, Type, Any, List from IPython.utils.decorators import undoc -from ..comm import CommManager +from .comm import CommManager from .kernelbase import Kernel as KernelBase from .serialize import serialize_object, unpack_apply_message from .zmqshell import ZMQInteractiveShell @@ -363,6 +363,6 @@ class IPythonKernel(KernelBase): class Kernel(IPythonKernel): def __init__(self, *args, **kwargs): import warnings - warnings.warn('Kernel is a deprecated alias of ipython_kernel.zmq.ipkernel.IPythonKernel', + warnings.warn('Kernel is a deprecated alias of ipython_kernel.ipkernel.IPythonKernel', DeprecationWarning) super(Kernel, self).__init__(*args, **kwargs) diff --git a/ipython_kernel/zmq/kernelapp.py b/ipython_kernel/kernelapp.py similarity index 97% rename from ipython_kernel/zmq/kernelapp.py rename to ipython_kernel/kernelapp.py index f88590d..9b32953 100644 --- a/ipython_kernel/zmq/kernelapp.py +++ b/ipython_kernel/kernelapp.py @@ -99,8 +99,8 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, flags = Dict(kernel_flags) classes = [IPythonKernel, ZMQInteractiveShell, ProfileDir, Session] # the kernel class, as an importstring - kernel_class = Type('ipython_kernel.zmq.ipkernel.IPythonKernel', config=True, - klass='ipython_kernel.zmq.kernelbase.Kernel', + kernel_class = Type('ipython_kernel.ipkernel.IPythonKernel', config=True, + klass='ipython_kernel.kernelbase.Kernel', help="""The Kernel subclass to be used. This should allow easy re-use of the IPKernelApp entry point @@ -124,9 +124,9 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, # streams, etc. no_stdout = Bool(False, config=True, help="redirect stdout to the null device") no_stderr = Bool(False, config=True, help="redirect stderr to the null device") - outstream_class = DottedObjectName('ipython_kernel.zmq.iostream.OutStream', + outstream_class = DottedObjectName('ipython_kernel.iostream.OutStream', config=True, help="The importstring for the OutStream factory") - displayhook_class = DottedObjectName('ipython_kernel.zmq.displayhook.ZMQDisplayHook', + displayhook_class = DottedObjectName('ipython_kernel.displayhook.ZMQDisplayHook', config=True, help="The importstring for the DisplayHook factory") # polling diff --git a/ipython_kernel/zmq/kernelbase.py b/ipython_kernel/kernelbase.py similarity index 100% rename from ipython_kernel/zmq/kernelbase.py rename to ipython_kernel/kernelbase.py old mode 100755 new mode 100644 index 6e5d346..ef95901 --- a/ipython_kernel/zmq/kernelbase.py +++ b/ipython_kernel/kernelbase.py @@ -324,7 +324,7 @@ class Kernel(SingletonConfigurable): buffers=None, track=False, header=None, metadata=None): """Send a response to the message we're currently processing. - This accepts all the parameters of :meth:`ipython_kernel.zmq.session.Session.send` + This accepts all the parameters of :meth:`ipython_kernel.session.Session.send` except ``parent``. This relies on :meth:`set_parent` having been called for the current diff --git a/ipython_kernel/zmq/log.py b/ipython_kernel/log.py similarity index 100% rename from ipython_kernel/zmq/log.py rename to ipython_kernel/log.py diff --git a/ipython_kernel/zmq/parentpoller.py b/ipython_kernel/parentpoller.py similarity index 100% rename from ipython_kernel/zmq/parentpoller.py rename to ipython_kernel/parentpoller.py diff --git a/ipython_kernel/zmq/pylab/__init__.py b/ipython_kernel/pylab/__init__.py similarity index 100% rename from ipython_kernel/zmq/pylab/__init__.py rename to ipython_kernel/pylab/__init__.py diff --git a/ipython_kernel/zmq/pylab/backend_inline.py b/ipython_kernel/pylab/backend_inline.py similarity index 100% rename from ipython_kernel/zmq/pylab/backend_inline.py rename to ipython_kernel/pylab/backend_inline.py diff --git a/ipython_kernel/zmq/pylab/config.py b/ipython_kernel/pylab/config.py similarity index 100% rename from ipython_kernel/zmq/pylab/config.py rename to ipython_kernel/pylab/config.py diff --git a/ipython_kernel/zmq/serialize.py b/ipython_kernel/serialize.py similarity index 100% rename from ipython_kernel/zmq/serialize.py rename to ipython_kernel/serialize.py diff --git a/ipython_kernel/zmq/session.py b/ipython_kernel/session.py similarity index 100% rename from ipython_kernel/zmq/session.py rename to ipython_kernel/session.py diff --git a/ipython_kernel/zmq/tests/test_embed_kernel.py b/ipython_kernel/tests/test_embed_kernel.py similarity index 100% rename from ipython_kernel/zmq/tests/test_embed_kernel.py rename to ipython_kernel/tests/test_embed_kernel.py diff --git a/ipython_kernel/zmq/tests/test_serialize.py b/ipython_kernel/tests/test_serialize.py similarity index 99% rename from ipython_kernel/zmq/tests/test_serialize.py rename to ipython_kernel/tests/test_serialize.py index 616b24b..2b8b37d 100644 --- a/ipython_kernel/zmq/tests/test_serialize.py +++ b/ipython_kernel/tests/test_serialize.py @@ -9,7 +9,7 @@ from collections import namedtuple import nose.tools as nt # from unittest import TestCaes -from ipython_kernel.zmq.serialize import serialize_object, deserialize_object +from ipython_kernel.serialize import serialize_object, deserialize_object from IPython.testing import decorators as dec from IPython.utils.pickleutil import CannedArray, CannedClass from IPython.utils.py3compat import iteritems diff --git a/ipython_kernel/zmq/tests/test_start_kernel.py b/ipython_kernel/tests/test_start_kernel.py similarity index 100% rename from ipython_kernel/zmq/tests/test_start_kernel.py rename to ipython_kernel/tests/test_start_kernel.py diff --git a/ipython_kernel/zmq/__init__.py b/ipython_kernel/zmq/__init__.py deleted file mode 100644 index bb58d44..0000000 --- a/ipython_kernel/zmq/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) IPython Development Team. -# Distributed under the terms of the Modified BSD License. - -# Verify zmq version dependency - -from IPython.utils.zmqrelated import check_for_zmq - -check_for_zmq('13', 'ipython_kernel.zmq') - -from jupyter_client import session -Session = session.Session diff --git a/ipython_kernel/zmq/tests/__init__.py b/ipython_kernel/zmq/tests/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/ipython_kernel/zmq/tests/__init__.py +++ /dev/null diff --git a/ipython_kernel/zmq/zmqshell.py b/ipython_kernel/zmqshell.py similarity index 98% rename from ipython_kernel/zmq/zmqshell.py rename to ipython_kernel/zmqshell.py index 04b5b44..e48dc81 100644 --- a/ipython_kernel/zmq/zmqshell.py +++ b/ipython_kernel/zmqshell.py @@ -46,9 +46,9 @@ from IPython.utils import py3compat from IPython.utils.py3compat import unicode_type from IPython.utils.traitlets import Instance, Type, Dict, CBool, CBytes, Any from IPython.utils.warn import error -from ipython_kernel.zmq.displayhook import ZMQShellDisplayHook -from ipython_kernel.zmq.datapub import ZMQDataPublisher -from ipython_kernel.zmq.session import extract_header +from ipython_kernel.displayhook import ZMQShellDisplayHook +from ipython_kernel.datapub import ZMQDataPublisher +from ipython_kernel.session import extract_header from .session import Session #-----------------------------------------------------------------------------