Show More
@@ -1,68 +1,73 b'' | |||
|
1 | 1 | #----------------------------------------------------------------------------- |
|
2 |
# Copyright (C) 2010 |
|
|
2 | # Copyright (C) 2010 The IPython Development Team | |
|
3 | 3 | # |
|
4 | 4 | # Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | # the file COPYING.txt, distributed as part of this software. |
|
6 | 6 | #----------------------------------------------------------------------------- |
|
7 | 7 | |
|
8 | 8 | #----------------------------------------------------------------------------- |
|
9 | 9 | # Verify zmq version dependency >= 2.1.4 |
|
10 | 10 | #----------------------------------------------------------------------------- |
|
11 | 11 | |
|
12 | 12 | import warnings |
|
13 | 13 | from distutils.version import LooseVersion as V |
|
14 | 14 | |
|
15 | 15 | |
|
16 | 16 | def patch_pyzmq(): |
|
17 | 17 | """backport a few patches from newer pyzmq |
|
18 | 18 | |
|
19 | 19 | These can be removed as we bump our minimum pyzmq version |
|
20 | 20 | """ |
|
21 | 21 | |
|
22 | 22 | import zmq |
|
23 | 23 | |
|
24 | 24 | # ioloop.install, introduced in pyzmq 2.1.7 |
|
25 | 25 | from zmq.eventloop import ioloop |
|
26 | 26 | |
|
27 | 27 | def install(): |
|
28 | 28 | import tornado.ioloop |
|
29 | 29 | tornado.ioloop.IOLoop = ioloop.IOLoop |
|
30 | 30 | |
|
31 | 31 | if not hasattr(ioloop, 'install'): |
|
32 | 32 | ioloop.install = install |
|
33 | 33 | |
|
34 | 34 | # fix missing DEALER/ROUTER aliases in pyzmq < 2.1.9 |
|
35 | 35 | if not hasattr(zmq, 'DEALER'): |
|
36 | 36 | zmq.DEALER = zmq.XREQ |
|
37 | 37 | if not hasattr(zmq, 'ROUTER'): |
|
38 | 38 | zmq.ROUTER = zmq.XREP |
|
39 | 39 | |
|
40 | 40 | # fallback on stdlib json if jsonlib is selected, because jsonlib breaks things. |
|
41 | 41 | # jsonlib support is removed from pyzmq >= 2.2.0 |
|
42 | 42 | |
|
43 | 43 | from zmq.utils import jsonapi |
|
44 | 44 | if jsonapi.jsonmod.__name__ == 'jsonlib': |
|
45 | 45 | import json |
|
46 | 46 | jsonapi.jsonmod = json |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | def check_for_zmq(minimum_version, module='IPython.zmq'): |
|
50 | 50 | try: |
|
51 | 51 | import zmq |
|
52 | 52 | except ImportError: |
|
53 | 53 | raise ImportError("%s requires pyzmq >= %s"%(module, minimum_version)) |
|
54 | 54 | |
|
55 | 55 | pyzmq_version = zmq.__version__ |
|
56 | 56 | |
|
57 | 57 | if 'dev' not in pyzmq_version and V(pyzmq_version) < V(minimum_version): |
|
58 | 58 | raise ImportError("%s requires pyzmq >= %s, but you have %s"%( |
|
59 | 59 | module, minimum_version, pyzmq_version)) |
|
60 | 60 | |
|
61 | 61 | if V(zmq.zmq_version()) >= V('4.0.0'): |
|
62 | 62 | warnings.warn("""libzmq 4 detected. |
|
63 | 63 | It is unlikely that IPython's zmq code will work properly. |
|
64 | 64 | Please install libzmq stable, which is 2.1.x or 2.2.x""", |
|
65 | 65 | RuntimeWarning) |
|
66 | 66 | |
|
67 | 67 | check_for_zmq('2.1.4') |
|
68 | 68 | patch_pyzmq() |
|
69 | ||
|
70 | from .blockingkernelmanager import BlockingKernelManager | |
|
71 | from .kernelmanager import * | |
|
72 | from .session import Session | |
|
73 |
General Comments 0
You need to be logged in to leave comments.
Login now