Show More
@@ -0,0 +1,47 | |||||
|
1 | """utilities for checking zmq versions""" | |||
|
2 | #----------------------------------------------------------------------------- | |||
|
3 | # Copyright (C) 2013 The IPython Development Team | |||
|
4 | # | |||
|
5 | # Distributed under the terms of the BSD License. The full license is in | |||
|
6 | # the file COPYING.txt, distributed as part of this software. | |||
|
7 | #----------------------------------------------------------------------------- | |||
|
8 | ||||
|
9 | #----------------------------------------------------------------------------- | |||
|
10 | # Verify zmq version dependency >= 2.1.11 | |||
|
11 | #----------------------------------------------------------------------------- | |||
|
12 | ||||
|
13 | import warnings | |||
|
14 | from IPython.utils.version import check_version | |||
|
15 | ||||
|
16 | ||||
|
17 | def patch_pyzmq(): | |||
|
18 | """backport a few patches from newer pyzmq | |||
|
19 | ||||
|
20 | These can be removed as we bump our minimum pyzmq version | |||
|
21 | """ | |||
|
22 | ||||
|
23 | import zmq | |||
|
24 | ||||
|
25 | # fallback on stdlib json if jsonlib is selected, because jsonlib breaks things. | |||
|
26 | # jsonlib support is removed from pyzmq >= 2.2.0 | |||
|
27 | ||||
|
28 | from zmq.utils import jsonapi | |||
|
29 | if jsonapi.jsonmod.__name__ == 'jsonlib': | |||
|
30 | import json | |||
|
31 | jsonapi.jsonmod = json | |||
|
32 | ||||
|
33 | ||||
|
34 | def check_for_zmq(minimum_version, required_by='Someone'): | |||
|
35 | try: | |||
|
36 | import zmq | |||
|
37 | except ImportError: | |||
|
38 | raise ImportError("%s requires pyzmq >= %s"%(required_by, minimum_version)) | |||
|
39 | ||||
|
40 | patch_pyzmq() | |||
|
41 | ||||
|
42 | pyzmq_version = zmq.__version__ | |||
|
43 | ||||
|
44 | if not check_version(pyzmq_version, minimum_version): | |||
|
45 | raise ImportError("%s requires pyzmq >= %s, but you have %s"%( | |||
|
46 | required_by, minimum_version, pyzmq_version)) | |||
|
47 |
@@ -1,20 +1,7 | |||||
1 | """The IPython HTML Notebook""" |
|
1 | """The IPython HTML Notebook""" | |
2 |
|
2 | |||
3 | # check for tornado 2.1.0 |
|
3 | import os | |
4 | msg = "The IPython Notebook requires tornado >= 2.1.0" |
|
4 | # Packagers: modify this line if you store the notebook static files elsewhere | |
5 | try: |
|
5 | DEFAULT_STATIC_FILES_PATH = os.path.join(os.path.dirname(__file__), "static") | |
6 | import tornado |
|
|||
7 | except ImportError: |
|
|||
8 | raise ImportError(msg) |
|
|||
9 | try: |
|
|||
10 | version_info = tornado.version_info |
|
|||
11 | except AttributeError: |
|
|||
12 | raise ImportError(msg + ", but you have < 1.1.0") |
|
|||
13 | if version_info < (2,1,0): |
|
|||
14 | raise ImportError(msg + ", but you have %s" % tornado.version) |
|
|||
15 | del msg |
|
|||
16 |
|
6 | |||
17 | # check for pyzmq 2.1.4 |
|
7 | del os | |
18 | from IPython.kernel.zmq import check_for_zmq |
|
|||
19 | check_for_zmq('2.1.4', 'IPython.frontend.html.notebook') |
|
|||
20 | del check_for_zmq |
|
@@ -31,7 +31,12 import time | |||||
31 | import uuid |
|
31 | import uuid | |
32 | import webbrowser |
|
32 | import webbrowser | |
33 |
|
33 | |||
|
34 | ||||
34 | # Third party |
|
35 | # Third party | |
|
36 | # check for pyzmq 2.1.11 | |||
|
37 | from IPython.utils.zmqrelated import check_for_zmq | |||
|
38 | check_for_zmq('2.1.11', 'IPython.frontend.html.notebook') | |||
|
39 | ||||
35 | import zmq |
|
40 | import zmq | |
36 | from jinja2 import Environment, FileSystemLoader |
|
41 | from jinja2 import Environment, FileSystemLoader | |
37 |
|
42 | |||
@@ -40,11 +45,24 from jinja2 import Environment, FileSystemLoader | |||||
40 | from zmq.eventloop import ioloop |
|
45 | from zmq.eventloop import ioloop | |
41 | ioloop.install() |
|
46 | ioloop.install() | |
42 |
|
47 | |||
43 | import tornado |
|
48 | # check for tornado 2.1.0 | |
|
49 | msg = "The IPython Notebook requires tornado >= 2.1.0" | |||
|
50 | try: | |||
|
51 | import tornado | |||
|
52 | except ImportError: | |||
|
53 | raise ImportError(msg) | |||
|
54 | try: | |||
|
55 | version_info = tornado.version_info | |||
|
56 | except AttributeError: | |||
|
57 | raise ImportError(msg + ", but you have < 1.1.0") | |||
|
58 | if version_info < (2,1,0): | |||
|
59 | raise ImportError(msg + ", but you have %s" % tornado.version) | |||
|
60 | ||||
44 | from tornado import httpserver |
|
61 | from tornado import httpserver | |
45 | from tornado import web |
|
62 | from tornado import web | |
46 |
|
63 | |||
47 | # Our own libraries |
|
64 | # Our own libraries | |
|
65 | from IPython.frontend.html.notebook import DEFAULT_STATIC_FILES_PATH | |||
48 | from .kernelmanager import MappingKernelManager |
|
66 | from .kernelmanager import MappingKernelManager | |
49 | from .handlers import (LoginHandler, LogoutHandler, |
|
67 | from .handlers import (LoginHandler, LogoutHandler, | |
50 | ProjectDashboardHandler, NewHandler, NamedNotebookHandler, |
|
68 | ProjectDashboardHandler, NewHandler, NamedNotebookHandler, | |
@@ -98,9 +116,6 ipython notebook --certfile=mycert.pem # use SSL/TLS certificate | |||||
98 | ipython notebook --port=5555 --ip=* # Listen on port 5555, all interfaces |
|
116 | ipython notebook --port=5555 --ip=* # Listen on port 5555, all interfaces | |
99 | """ |
|
117 | """ | |
100 |
|
118 | |||
101 | # Packagers: modify this line if you store the notebook static files elsewhere |
|
|||
102 | DEFAULT_STATIC_FILES_PATH = os.path.join(os.path.dirname(__file__), "static") |
|
|||
103 |
|
||||
104 | #----------------------------------------------------------------------------- |
|
119 | #----------------------------------------------------------------------------- | |
105 | # Helper functions |
|
120 | # Helper functions | |
106 | #----------------------------------------------------------------------------- |
|
121 | #----------------------------------------------------------------------------- | |
@@ -569,19 +584,7 class NotebookApp(BaseIPythonApplication): | |||||
569 | self.exit(1) |
|
584 | self.exit(1) | |
570 |
|
585 | |||
571 | def init_signal(self): |
|
586 | def init_signal(self): | |
572 | # FIXME: remove this check when pyzmq dependency is >= 2.1.11 |
|
587 | if not sys.platform.startswith('win'): | |
573 | # safely extract zmq version info: |
|
|||
574 | try: |
|
|||
575 | zmq_v = zmq.pyzmq_version_info() |
|
|||
576 | except AttributeError: |
|
|||
577 | zmq_v = [ int(n) for n in re.findall(r'\d+', zmq.__version__) ] |
|
|||
578 | if 'dev' in zmq.__version__: |
|
|||
579 | zmq_v.append(999) |
|
|||
580 | zmq_v = tuple(zmq_v) |
|
|||
581 | if zmq_v >= (2,1,9) and not sys.platform.startswith('win'): |
|
|||
582 | # This won't work with 2.1.7 and |
|
|||
583 | # 2.1.9-10 will log ugly 'Interrupted system call' messages, |
|
|||
584 | # but it will work |
|
|||
585 | signal.signal(signal.SIGINT, self._handle_sigint) |
|
588 | signal.signal(signal.SIGINT, self._handle_sigint) | |
586 | signal.signal(signal.SIGTERM, self._signal_stop) |
|
589 | signal.signal(signal.SIGTERM, self._signal_stop) | |
587 | if hasattr(signal, 'SIGUSR1'): |
|
590 | if hasattr(signal, 'SIGUSR1'): |
@@ -1,5 +1,8 | |||||
1 | """IPython kernels and associated utilities""" |
|
1 | """IPython kernels and associated utilities""" | |
2 |
|
2 | |||
|
3 | # just for friendlier zmq version check | |||
|
4 | from . import zmq | |||
|
5 | ||||
3 | from .connect import * |
|
6 | from .connect import * | |
4 | from .launcher import * |
|
7 | from .launcher import * | |
5 | from .kernelmanager import KernelManager |
|
8 | from .kernelmanager import KernelManager |
@@ -1,5 +1,5 | |||||
1 | #----------------------------------------------------------------------------- |
|
1 | #----------------------------------------------------------------------------- | |
2 |
# Copyright (C) 201 |
|
2 | # Copyright (C) 2013 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. | |
@@ -9,41 +9,9 | |||||
9 | # Verify zmq version dependency >= 2.1.11 |
|
9 | # Verify zmq version dependency >= 2.1.11 | |
10 | #----------------------------------------------------------------------------- |
|
10 | #----------------------------------------------------------------------------- | |
11 |
|
11 | |||
12 | import warnings |
|
12 | from IPython.utils.zmqrelated import check_for_zmq | |
13 | from IPython.utils.version import check_version |
|
|||
14 |
|
13 | |||
15 |
|
14 | check_for_zmq('2.1.11', 'IPython.kernel.zmq') | ||
16 | def patch_pyzmq(): |
|
|||
17 | """backport a few patches from newer pyzmq |
|
|||
18 |
|
||||
19 | These can be removed as we bump our minimum pyzmq version |
|
|||
20 | """ |
|
|||
21 |
|
||||
22 | import zmq |
|
|||
23 |
|
||||
24 | # fallback on stdlib json if jsonlib is selected, because jsonlib breaks things. |
|
|||
25 | # jsonlib support is removed from pyzmq >= 2.2.0 |
|
|||
26 |
|
||||
27 | from zmq.utils import jsonapi |
|
|||
28 | if jsonapi.jsonmod.__name__ == 'jsonlib': |
|
|||
29 | import json |
|
|||
30 | jsonapi.jsonmod = json |
|
|||
31 |
|
||||
32 |
|
||||
33 | def check_for_zmq(minimum_version, module='IPython.kernel.zmq'): |
|
|||
34 | try: |
|
|||
35 | import zmq |
|
|||
36 | except ImportError: |
|
|||
37 | raise ImportError("%s requires pyzmq >= %s"%(module, minimum_version)) |
|
|||
38 |
|
||||
39 | pyzmq_version = zmq.__version__ |
|
|||
40 |
|
||||
41 | if not check_version(pyzmq_version, minimum_version): |
|
|||
42 | raise ImportError("%s requires pyzmq >= %s, but you have %s"%( |
|
|||
43 | module, minimum_version, pyzmq_version)) |
|
|||
44 |
|
||||
45 | check_for_zmq('2.1.11') |
|
|||
46 | patch_pyzmq() |
|
|||
47 |
|
15 | |||
48 | from .session import Session |
|
16 | from .session import Session | |
49 |
|
17 |
@@ -21,7 +21,7 import warnings | |||||
21 | import zmq |
|
21 | import zmq | |
22 |
|
22 | |||
23 | from IPython.config.configurable import MultipleInstanceError |
|
23 | from IPython.config.configurable import MultipleInstanceError | |
24 |
from IPython. |
|
24 | from IPython.utils.zmqrelated import check_for_zmq | |
25 |
|
25 | |||
26 | min_pyzmq = '2.1.11' |
|
26 | min_pyzmq = '2.1.11' | |
27 |
|
27 |
General Comments 0
You need to be logged in to leave comments.
Login now