Show More
@@ -1,42 +1,39 b'' | |||||
1 | #----------------------------------------------------------------------------- |
|
1 | #----------------------------------------------------------------------------- | |
2 | # Copyright (C) 2010-2011 The IPython Development Team |
|
2 | # Copyright (C) 2010-2011 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 re |
|
|||
13 | import warnings |
|
12 | import warnings | |
|
13 | from distutils.version import LooseVersion as V | |||
14 |
|
14 | |||
15 | def check_for_zmq(minimum_version, module='IPython.zmq'): |
|
15 | def check_for_zmq(minimum_version, module='IPython.zmq'): | |
16 | min_vlist = [int(n) for n in minimum_version.split('.')] |
|
|||
17 |
|
||||
18 | try: |
|
16 | try: | |
19 | import zmq |
|
17 | import zmq | |
20 | except ImportError: |
|
18 | except ImportError: | |
21 | raise ImportError("%s requires pyzmq >= %s"%(module, minimum_version)) |
|
19 | raise ImportError("%s requires pyzmq >= %s"%(module, minimum_version)) | |
22 |
|
20 | |||
23 | pyzmq_version = zmq.__version__ |
|
21 | pyzmq_version = zmq.__version__ | |
24 | vlist = [int(n) for n in re.findall(r'\d+', pyzmq_version)] |
|
22 | ||
25 |
|
23 | if 'dev' not in pyzmq_version and V(pyzmq_version) < V(minimum_version): | ||
26 | if 'dev' not in pyzmq_version and vlist < min_vlist: |
|
|||
27 | raise ImportError("%s requires pyzmq >= %s, but you have %s"%( |
|
24 | raise ImportError("%s requires pyzmq >= %s, but you have %s"%( | |
28 | module, minimum_version, pyzmq_version)) |
|
25 | module, minimum_version, pyzmq_version)) | |
29 |
|
26 | |||
30 | # fix missing DEALER/ROUTER aliases in pyzmq < 2.1.9 |
|
27 | # fix missing DEALER/ROUTER aliases in pyzmq < 2.1.9 | |
31 | if not hasattr(zmq, 'DEALER'): |
|
28 | if not hasattr(zmq, 'DEALER'): | |
32 | zmq.DEALER = zmq.XREQ |
|
29 | zmq.DEALER = zmq.XREQ | |
33 | if not hasattr(zmq, 'ROUTER'): |
|
30 | if not hasattr(zmq, 'ROUTER'): | |
34 | zmq.ROUTER = zmq.XREP |
|
31 | zmq.ROUTER = zmq.XREP | |
35 |
|
32 | |||
36 | if zmq.zmq_version() >= '4.0.0': |
|
33 | if V(zmq.zmq_version()) >= V('4.0.0'): | |
37 | warnings.warn("""libzmq 4 detected. |
|
34 | warnings.warn("""libzmq 4 detected. | |
38 | It is unlikely that IPython's zmq code will work properly. |
|
35 | It is unlikely that IPython's zmq code will work properly. | |
39 | Please install libzmq stable, which is 2.1.x or 2.2.x""", |
|
36 | Please install libzmq stable, which is 2.1.x or 2.2.x""", | |
40 | RuntimeWarning) |
|
37 | RuntimeWarning) | |
41 |
|
38 | |||
42 | check_for_zmq('2.1.4') |
|
39 | check_for_zmq('2.1.4') |
General Comments 0
You need to be logged in to leave comments.
Login now