Show More
@@ -23,10 +23,7 b' import zmq' | |||||
23 | from IPython.config.configurable import MultipleInstanceError |
|
23 | from IPython.config.configurable import MultipleInstanceError | |
24 | from IPython.zmq import check_for_zmq |
|
24 | from IPython.zmq import check_for_zmq | |
25 |
|
25 | |||
26 | if os.name == 'nt': |
|
26 | min_pyzmq = '2.1.11' | |
27 | min_pyzmq = '2.1.7' |
|
|||
28 | else: |
|
|||
29 | min_pyzmq = '2.1.4' |
|
|||
30 |
|
27 | |||
31 | check_for_zmq(min_pyzmq, 'IPython.parallel') |
|
28 | check_for_zmq(min_pyzmq, 'IPython.parallel') | |
32 |
|
29 |
@@ -167,19 +167,9 b" have['wx'] = test_for('wx')" | |||||
167 | have['wx.aui'] = test_for('wx.aui') |
|
167 | have['wx.aui'] = test_for('wx.aui') | |
168 | have['azure'] = test_for('azure') |
|
168 | have['azure'] = test_for('azure') | |
169 |
|
169 | |||
170 | if os.name == 'nt': |
|
170 | min_zmq = (2,1,11) | |
171 | min_zmq = (2,1,7) |
|
171 | ||
172 | else: |
|
172 | have['zmq'] = test_for('zmq.pyzmq_version_info', min_zmq, callback=lambda x: x()) | |
173 | min_zmq = (2,1,4) |
|
|||
174 |
|
||||
175 | def version_tuple(mod): |
|
|||
176 | "turn '2.1.9' into (2,1,9), and '2.1dev' into (2,1,999)" |
|
|||
177 | # turn 'dev' into 999, because Python3 rejects str-int comparisons |
|
|||
178 | vs = mod.__version__.replace('dev', '.999') |
|
|||
179 | tup = tuple([int(v) for v in vs.split('.') ]) |
|
|||
180 | return tup |
|
|||
181 |
|
||||
182 | have['zmq'] = test_for('zmq', min_zmq, version_tuple) |
|
|||
183 |
|
173 | |||
184 | #----------------------------------------------------------------------------- |
|
174 | #----------------------------------------------------------------------------- | |
185 | # Functions and classes |
|
175 | # Functions and classes |
@@ -6,11 +6,11 b'' | |||||
6 | #----------------------------------------------------------------------------- |
|
6 | #----------------------------------------------------------------------------- | |
7 |
|
7 | |||
8 | #----------------------------------------------------------------------------- |
|
8 | #----------------------------------------------------------------------------- | |
9 |
# Verify zmq version dependency >= 2.1. |
|
9 | # Verify zmq version dependency >= 2.1.11 | |
10 | #----------------------------------------------------------------------------- |
|
10 | #----------------------------------------------------------------------------- | |
11 |
|
11 | |||
12 | import warnings |
|
12 | import warnings | |
13 |
from |
|
13 | from IPython.utils.version import check_version | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | def patch_pyzmq(): |
|
16 | def patch_pyzmq(): | |
@@ -21,22 +21,6 b' def patch_pyzmq():' | |||||
21 |
|
21 | |||
22 | import zmq |
|
22 | import zmq | |
23 |
|
23 | |||
24 | # ioloop.install, introduced in pyzmq 2.1.7 |
|
|||
25 | from zmq.eventloop import ioloop |
|
|||
26 |
|
||||
27 | def install(): |
|
|||
28 | import tornado.ioloop |
|
|||
29 | tornado.ioloop.IOLoop = ioloop.IOLoop |
|
|||
30 |
|
||||
31 | if not hasattr(ioloop, 'install'): |
|
|||
32 | ioloop.install = install |
|
|||
33 |
|
||||
34 | # fix missing DEALER/ROUTER aliases in pyzmq < 2.1.9 |
|
|||
35 | if not hasattr(zmq, 'DEALER'): |
|
|||
36 | zmq.DEALER = zmq.XREQ |
|
|||
37 | if not hasattr(zmq, 'ROUTER'): |
|
|||
38 | zmq.ROUTER = zmq.XREP |
|
|||
39 |
|
||||
40 | # fallback on stdlib json if jsonlib is selected, because jsonlib breaks things. |
|
24 | # fallback on stdlib json if jsonlib is selected, because jsonlib breaks things. | |
41 | # jsonlib support is removed from pyzmq >= 2.2.0 |
|
25 | # jsonlib support is removed from pyzmq >= 2.2.0 | |
42 |
|
26 | |||
@@ -54,17 +38,11 b" def check_for_zmq(minimum_version, module='IPython.zmq'):" | |||||
54 |
|
38 | |||
55 | pyzmq_version = zmq.__version__ |
|
39 | pyzmq_version = zmq.__version__ | |
56 |
|
40 | |||
57 |
if |
|
41 | if not check_version(pyzmq_version, minimum_version): | |
58 | raise ImportError("%s requires pyzmq >= %s, but you have %s"%( |
|
42 | raise ImportError("%s requires pyzmq >= %s, but you have %s"%( | |
59 | module, minimum_version, pyzmq_version)) |
|
43 | module, minimum_version, pyzmq_version)) | |
60 |
|
44 | |||
61 | if V(zmq.zmq_version()) >= V('4.0.0'): |
|
45 | check_for_zmq('2.1.11') | |
62 | warnings.warn("""libzmq 4 detected. |
|
|||
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""", |
|
|||
65 | RuntimeWarning) |
|
|||
66 |
|
||||
67 | check_for_zmq('2.1.4') |
|
|||
68 | patch_pyzmq() |
|
46 | patch_pyzmq() | |
69 |
|
47 | |||
70 | from .blockingkernelmanager import BlockingKernelManager |
|
48 | from .blockingkernelmanager import BlockingKernelManager |
@@ -27,21 +27,6 b' class SessionTestCase(BaseZMQTestCase):' | |||||
27 | self.session = ss.Session() |
|
27 | self.session = ss.Session() | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | class MockSocket(zmq.Socket): |
|
|||
31 |
|
||||
32 | def __init__(self, *args, **kwargs): |
|
|||
33 | super(MockSocket,self).__init__(*args,**kwargs) |
|
|||
34 | self.data = [] |
|
|||
35 |
|
||||
36 | def send_multipart(self, msgparts, *args, **kwargs): |
|
|||
37 | self.data.extend(msgparts) |
|
|||
38 |
|
||||
39 | def send(self, part, *args, **kwargs): |
|
|||
40 | self.data.append(part) |
|
|||
41 |
|
||||
42 | def recv_multipart(self, *args, **kwargs): |
|
|||
43 | return self.data |
|
|||
44 |
|
||||
45 | class TestSession(SessionTestCase): |
|
30 | class TestSession(SessionTestCase): | |
46 |
|
31 | |||
47 | def test_msg(self): |
|
32 | def test_msg(self): | |
@@ -75,11 +60,16 b' class TestSession(SessionTestCase):' | |||||
75 | self.assertEqual(type(new_msg['content']['b']),type(new_msg['content']['b'])) |
|
60 | self.assertEqual(type(new_msg['content']['b']),type(new_msg['content']['b'])) | |
76 |
|
61 | |||
77 | def test_send(self): |
|
62 | def test_send(self): | |
78 |
|
|
63 | ctx = zmq.Context.instance() | |
|
64 | A = ctx.socket(zmq.PAIR) | |||
|
65 | B = ctx.socket(zmq.PAIR) | |||
|
66 | A.bind("inproc://test") | |||
|
67 | B.connect("inproc://test") | |||
79 |
|
68 | |||
80 | msg = self.session.msg('execute', content=dict(a=10)) |
|
69 | msg = self.session.msg('execute', content=dict(a=10)) | |
81 |
self.session.send( |
|
70 | self.session.send(A, msg, ident=b'foo', buffers=[b'bar']) | |
82 | ident, msg_list = self.session.feed_identities(socket.data) |
|
71 | ||
|
72 | ident, msg_list = self.session.feed_identities(B.recv_multipart()) | |||
83 | new_msg = self.session.unserialize(msg_list) |
|
73 | new_msg = self.session.unserialize(msg_list) | |
84 | self.assertEqual(ident[0], b'foo') |
|
74 | self.assertEqual(ident[0], b'foo') | |
85 | self.assertEqual(new_msg['msg_id'],msg['msg_id']) |
|
75 | self.assertEqual(new_msg['msg_id'],msg['msg_id']) | |
@@ -90,16 +80,14 b' class TestSession(SessionTestCase):' | |||||
90 | self.assertEqual(new_msg['metadata'],msg['metadata']) |
|
80 | self.assertEqual(new_msg['metadata'],msg['metadata']) | |
91 | self.assertEqual(new_msg['buffers'],[b'bar']) |
|
81 | self.assertEqual(new_msg['buffers'],[b'bar']) | |
92 |
|
82 | |||
93 | socket.data = [] |
|
|||
94 |
|
||||
95 | content = msg['content'] |
|
83 | content = msg['content'] | |
96 | header = msg['header'] |
|
84 | header = msg['header'] | |
97 | parent = msg['parent_header'] |
|
85 | parent = msg['parent_header'] | |
98 | metadata = msg['metadata'] |
|
86 | metadata = msg['metadata'] | |
99 | msg_type = header['msg_type'] |
|
87 | msg_type = header['msg_type'] | |
100 |
self.session.send( |
|
88 | self.session.send(A, None, content=content, parent=parent, | |
101 | header=header, metadata=metadata, ident=b'foo', buffers=[b'bar']) |
|
89 | header=header, metadata=metadata, ident=b'foo', buffers=[b'bar']) | |
102 |
ident, msg_list = self.session.feed_identities( |
|
90 | ident, msg_list = self.session.feed_identities(B.recv_multipart()) | |
103 | new_msg = self.session.unserialize(msg_list) |
|
91 | new_msg = self.session.unserialize(msg_list) | |
104 | self.assertEqual(ident[0], b'foo') |
|
92 | self.assertEqual(ident[0], b'foo') | |
105 | self.assertEqual(new_msg['msg_id'],msg['msg_id']) |
|
93 | self.assertEqual(new_msg['msg_id'],msg['msg_id']) | |
@@ -110,10 +98,8 b' class TestSession(SessionTestCase):' | |||||
110 | self.assertEqual(new_msg['parent_header'],msg['parent_header']) |
|
98 | self.assertEqual(new_msg['parent_header'],msg['parent_header']) | |
111 | self.assertEqual(new_msg['buffers'],[b'bar']) |
|
99 | self.assertEqual(new_msg['buffers'],[b'bar']) | |
112 |
|
100 | |||
113 | socket.data = [] |
|
101 | self.session.send(A, msg, ident=b'foo', buffers=[b'bar']) | |
114 |
|
102 | ident, new_msg = self.session.recv(B) | ||
115 | self.session.send(socket, msg, ident=b'foo', buffers=[b'bar']) |
|
|||
116 | ident, new_msg = self.session.recv(socket) |
|
|||
117 | self.assertEqual(ident[0], b'foo') |
|
103 | self.assertEqual(ident[0], b'foo') | |
118 | self.assertEqual(new_msg['msg_id'],msg['msg_id']) |
|
104 | self.assertEqual(new_msg['msg_id'],msg['msg_id']) | |
119 | self.assertEqual(new_msg['msg_type'],msg['msg_type']) |
|
105 | self.assertEqual(new_msg['msg_type'],msg['msg_type']) | |
@@ -123,7 +109,9 b' class TestSession(SessionTestCase):' | |||||
123 | self.assertEqual(new_msg['parent_header'],msg['parent_header']) |
|
109 | self.assertEqual(new_msg['parent_header'],msg['parent_header']) | |
124 | self.assertEqual(new_msg['buffers'],[b'bar']) |
|
110 | self.assertEqual(new_msg['buffers'],[b'bar']) | |
125 |
|
111 | |||
126 |
|
|
112 | A.close() | |
|
113 | B.close() | |||
|
114 | ctx.term() | |||
127 |
|
115 | |||
128 | def test_args(self): |
|
116 | def test_args(self): | |
129 | """initialization arguments for Session""" |
|
117 | """initialization arguments for Session""" |
@@ -229,12 +229,12 b" if 'setuptools' in sys.modules:" | |||||
229 | setuptools_extra_args['zip_safe'] = False |
|
229 | setuptools_extra_args['zip_safe'] = False | |
230 | setuptools_extra_args['entry_points'] = find_scripts(True) |
|
230 | setuptools_extra_args['entry_points'] = find_scripts(True) | |
231 | setup_args['extras_require'] = dict( |
|
231 | setup_args['extras_require'] = dict( | |
232 |
parallel = 'pyzmq>=2.1. |
|
232 | parallel = 'pyzmq>=2.1.11', | |
233 |
qtconsole = ['pyzmq>=2.1. |
|
233 | qtconsole = ['pyzmq>=2.1.11', 'pygments'], | |
234 |
zmq = 'pyzmq>=2.1. |
|
234 | zmq = 'pyzmq>=2.1.11', | |
235 | doc = 'Sphinx>=0.3', |
|
235 | doc = 'Sphinx>=0.3', | |
236 | test = 'nose>=0.10.1', |
|
236 | test = 'nose>=0.10.1', | |
237 |
notebook = ['tornado>=2.0', 'pyzmq>=2.1. |
|
237 | notebook = ['tornado>=2.0', 'pyzmq>=2.1.11', 'jinja2'], | |
238 | ) |
|
238 | ) | |
239 | requires = setup_args.setdefault('install_requires', []) |
|
239 | requires = setup_args.setdefault('install_requires', []) | |
240 | setupext.display_status = False |
|
240 | setupext.display_status = False |
@@ -142,23 +142,13 b' def check_for_pyzmq():' | |||||
142 | else: |
|
142 | else: | |
143 | # pyzmq 2.1.10 adds pyzmq_version_info funtion for returning |
|
143 | # pyzmq 2.1.10 adds pyzmq_version_info funtion for returning | |
144 | # version as a tuple |
|
144 | # version as a tuple | |
145 | if hasattr(zmq, 'pyzmq_version_info'): |
|
145 | if hasattr(zmq, 'pyzmq_version_info') and zmq.pyzmq_version_info() >= (2,1,11): | |
146 | if zmq.pyzmq_version_info() >= (2,1,4): |
|
|||
147 | print_status("pyzmq", zmq.__version__) |
|
146 | print_status("pyzmq", zmq.__version__) | |
148 | return True |
|
147 | return True | |
149 | else: |
|
|||
150 | # this branch can never occur, at least until we update our |
|
|||
151 | # pyzmq dependency beyond 2.1.10 |
|
|||
152 | return False |
|
|||
153 | # this is necessarily earlier than 2.1.10, so string comparison is |
|
|||
154 | # okay |
|
|||
155 | if zmq.__version__ < '2.1.4': |
|
|||
156 | print_status('pyzmq', "no (have %s, but require >= 2.1.4 for" |
|
|||
157 | " qtconsole and parallel computing capabilities)"%zmq.__version__) |
|
|||
158 | return False |
|
|||
159 | else: |
|
148 | else: | |
160 | print_status("pyzmq", zmq.__version__) |
|
149 | print_status('pyzmq', "no (have %s, but require >= 2.1.11 for" | |
161 | return True |
|
150 | " qtconsole, notebook, and parallel computing capabilities)" % zmq.__version__) | |
|
151 | return False | |||
162 |
|
152 | |||
163 | def check_for_readline(): |
|
153 | def check_for_readline(): | |
164 | from distutils.version import LooseVersion |
|
154 | from distutils.version import LooseVersion |
General Comments 0
You need to be logged in to leave comments.
Login now