diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py index 329d357..ff96f8c 100644 --- a/IPython/frontend/html/notebook/notebookapp.py +++ b/IPython/frontend/html/notebook/notebookapp.py @@ -33,8 +33,8 @@ import webbrowser # Third party -# check for pyzmq 2.1.11 (this is actually redundant) -from IPython.kernel.zmq import check_for_zmq +# check for pyzmq 2.1.11 +from IPython.utils.zmqrelated import check_for_zmq check_for_zmq('2.1.11', 'IPython.frontend.html.notebook') import zmq diff --git a/IPython/kernel/zmq/__init__.py b/IPython/kernel/zmq/__init__.py index 87927ad..0772c2a 100644 --- a/IPython/kernel/zmq/__init__.py +++ b/IPython/kernel/zmq/__init__.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Copyright (C) 2010 The IPython Development Team +# Copyright (C) 2013 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING.txt, distributed as part of this software. @@ -9,41 +9,9 @@ # Verify zmq version dependency >= 2.1.11 #----------------------------------------------------------------------------- -import warnings -from IPython.utils.version import check_version +from IPython.utils.zmqrelated import check_for_zmq - -def patch_pyzmq(): - """backport a few patches from newer pyzmq - - These can be removed as we bump our minimum pyzmq version - """ - - import zmq - - # fallback on stdlib json if jsonlib is selected, because jsonlib breaks things. - # jsonlib support is removed from pyzmq >= 2.2.0 - - from zmq.utils import jsonapi - if jsonapi.jsonmod.__name__ == 'jsonlib': - import json - jsonapi.jsonmod = json - - -def check_for_zmq(minimum_version, module='IPython.kernel.zmq'): - try: - import zmq - except ImportError: - raise ImportError("%s requires pyzmq >= %s"%(module, minimum_version)) - - pyzmq_version = zmq.__version__ - - if not check_version(pyzmq_version, minimum_version): - raise ImportError("%s requires pyzmq >= %s, but you have %s"%( - module, minimum_version, pyzmq_version)) - -check_for_zmq('2.1.11') -patch_pyzmq() +check_for_zmq('2.1.11', 'IPython.kernel.zmq') from .session import Session diff --git a/IPython/parallel/__init__.py b/IPython/parallel/__init__.py index 0692dd7..3f8cbcd 100644 --- a/IPython/parallel/__init__.py +++ b/IPython/parallel/__init__.py @@ -21,7 +21,7 @@ import warnings import zmq from IPython.config.configurable import MultipleInstanceError -from IPython.kernel.zmq import check_for_zmq +from IPython.utils.zmqrelated import check_for_zmq min_pyzmq = '2.1.11' diff --git a/IPython/utils/zmqrelated.py b/IPython/utils/zmqrelated.py new file mode 100644 index 0000000..8abbabb --- /dev/null +++ b/IPython/utils/zmqrelated.py @@ -0,0 +1,47 @@ +"""utilities for checking zmq versions""" +#----------------------------------------------------------------------------- +# Copyright (C) 2013 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING.txt, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Verify zmq version dependency >= 2.1.11 +#----------------------------------------------------------------------------- + +import warnings +from IPython.utils.version import check_version + + +def patch_pyzmq(): + """backport a few patches from newer pyzmq + + These can be removed as we bump our minimum pyzmq version + """ + + import zmq + + # fallback on stdlib json if jsonlib is selected, because jsonlib breaks things. + # jsonlib support is removed from pyzmq >= 2.2.0 + + from zmq.utils import jsonapi + if jsonapi.jsonmod.__name__ == 'jsonlib': + import json + jsonapi.jsonmod = json + + +def check_for_zmq(minimum_version, required_by='Someone'): + try: + import zmq + except ImportError: + raise ImportError("%s requires pyzmq >= %s"%(required_by, minimum_version)) + + patch_pyzmq() + + pyzmq_version = zmq.__version__ + + if not check_version(pyzmq_version, minimum_version): + raise ImportError("%s requires pyzmq >= %s, but you have %s"%( + required_by, minimum_version, pyzmq_version)) +