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