Show More
@@ -1,166 +1,169 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | from __future__ import print_function |
|
3 | 3 | |
|
4 | 4 | __docformat__ = "restructuredtext en" |
|
5 | 5 | |
|
6 | 6 | #------------------------------------------------------------------------------- |
|
7 | 7 | # Copyright (C) 2008 The IPython Development Team |
|
8 | 8 | # |
|
9 | 9 | # Distributed under the terms of the BSD License. The full license is in |
|
10 | 10 | # the file COPYING, distributed as part of this software. |
|
11 | 11 | #------------------------------------------------------------------------------- |
|
12 | 12 | |
|
13 | 13 | #------------------------------------------------------------------------------- |
|
14 | 14 | # Imports |
|
15 | 15 | #------------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | 17 | import sys, os |
|
18 | 18 | from textwrap import fill |
|
19 | 19 | |
|
20 | 20 | display_status=True |
|
21 | 21 | |
|
22 | 22 | def check_display(f): |
|
23 | 23 | """decorator to allow display methods to be muted by mod.display_status""" |
|
24 | 24 | def maybe_display(*args, **kwargs): |
|
25 | 25 | if display_status: |
|
26 | 26 | return f(*args, **kwargs) |
|
27 | 27 | return maybe_display |
|
28 | 28 | |
|
29 | 29 | @check_display |
|
30 | 30 | def print_line(char='='): |
|
31 | 31 | print(char * 76) |
|
32 | 32 | |
|
33 | 33 | @check_display |
|
34 | 34 | def print_status(package, status): |
|
35 | 35 | initial_indent = "%22s: " % package |
|
36 | 36 | indent = ' ' * 24 |
|
37 | 37 | print(fill(str(status), width=76, |
|
38 | 38 | initial_indent=initial_indent, |
|
39 | 39 | subsequent_indent=indent)) |
|
40 | 40 | |
|
41 | 41 | @check_display |
|
42 | 42 | def print_message(message): |
|
43 | 43 | indent = ' ' * 24 + "* " |
|
44 | 44 | print(fill(str(message), width=76, |
|
45 | 45 | initial_indent=indent, |
|
46 | 46 | subsequent_indent=indent)) |
|
47 | 47 | |
|
48 | 48 | @check_display |
|
49 | 49 | def print_raw(section): |
|
50 | 50 | print(section) |
|
51 | 51 | |
|
52 | 52 | #------------------------------------------------------------------------------- |
|
53 | 53 | # Tests for specific packages |
|
54 | 54 | #------------------------------------------------------------------------------- |
|
55 | 55 | |
|
56 | 56 | def check_for_ipython(): |
|
57 | 57 | try: |
|
58 | 58 | import IPython |
|
59 | 59 | except ImportError: |
|
60 | 60 | print_status("IPython", "Not found") |
|
61 | 61 | return False |
|
62 | 62 | else: |
|
63 | 63 | print_status("IPython", IPython.__version__) |
|
64 | 64 | return True |
|
65 | 65 | |
|
66 | 66 | def check_for_sphinx(): |
|
67 | 67 | try: |
|
68 | 68 | import sphinx |
|
69 | 69 | except ImportError: |
|
70 | 70 | print_status('sphinx', "Not found (required for docs and nbconvert)") |
|
71 | 71 | return False |
|
72 | 72 | else: |
|
73 | 73 | print_status('sphinx', sphinx.__version__) |
|
74 | 74 | return True |
|
75 | 75 | |
|
76 | 76 | def check_for_pygments(): |
|
77 | 77 | try: |
|
78 | 78 | import pygments |
|
79 | 79 | except ImportError: |
|
80 | 80 | print_status('pygments', "Not found (required for docs and nbconvert)") |
|
81 | 81 | return False |
|
82 | 82 | else: |
|
83 | 83 | print_status('pygments', pygments.__version__) |
|
84 | 84 | return True |
|
85 | 85 | |
|
86 | 86 | def check_for_jinja2(): |
|
87 | 87 | try: |
|
88 | 88 | import jinja2 |
|
89 | 89 | except ImportError: |
|
90 | 90 | print_status('jinja2', "Not found (required for notebook and nbconvert)") |
|
91 | 91 | return False |
|
92 | 92 | else: |
|
93 | 93 | print_status('jinja2', jinja2.__version__) |
|
94 | 94 | return True |
|
95 | 95 | |
|
96 | 96 | def check_for_nose(): |
|
97 | 97 | try: |
|
98 | 98 | import nose |
|
99 | 99 | except ImportError: |
|
100 | 100 | print_status('nose', "Not found (required for running the test suite)") |
|
101 | 101 | return False |
|
102 | 102 | else: |
|
103 | 103 | print_status('nose', nose.__version__) |
|
104 | 104 | return True |
|
105 | 105 | |
|
106 | 106 | def check_for_pexpect(): |
|
107 | 107 | try: |
|
108 | 108 | import pexpect |
|
109 | 109 | except ImportError: |
|
110 | 110 | print_status("pexpect", "no (required for running standalone doctests)") |
|
111 | 111 | return False |
|
112 | 112 | else: |
|
113 | 113 | print_status("pexpect", pexpect.__version__) |
|
114 | 114 | return True |
|
115 | 115 | |
|
116 | 116 | def check_for_pyzmq(): |
|
117 | 117 | try: |
|
118 | 118 | import zmq |
|
119 | 119 | except ImportError: |
|
120 | 120 | print_status('pyzmq', "no (required for qtconsole, notebook, and parallel computing capabilities)") |
|
121 | 121 | return False |
|
122 | 122 | else: |
|
123 | 123 | # pyzmq 2.1.10 adds pyzmq_version_info funtion for returning |
|
124 | 124 | # version as a tuple |
|
125 | 125 | if hasattr(zmq, 'pyzmq_version_info') and zmq.pyzmq_version_info() >= (2,1,11): |
|
126 | 126 | print_status("pyzmq", zmq.__version__) |
|
127 | 127 | return True |
|
128 | 128 | else: |
|
129 | 129 | print_status('pyzmq', "no (have %s, but require >= 2.1.11 for" |
|
130 | 130 | " qtconsole, notebook, and parallel computing capabilities)" % zmq.__version__) |
|
131 | 131 | return False |
|
132 | 132 | |
|
133 | 133 | def check_for_tornado(): |
|
134 | 134 | try: |
|
135 | 135 | import tornado |
|
136 | 136 | except ImportError: |
|
137 | 137 | print_status('tornado', "no (required for notebook)") |
|
138 | 138 | return False |
|
139 | 139 | else: |
|
140 | 140 | if getattr(tornado, 'version_info', (0,)) < (3,1): |
|
141 | 141 | print_status('tornado', "no (have %s, but require >= 3.1.0)" % tornado.version) |
|
142 | 142 | return False |
|
143 | 143 | else: |
|
144 | 144 | print_status('tornado', tornado.version) |
|
145 | 145 | return True |
|
146 | 146 | |
|
147 | 147 | def check_for_readline(): |
|
148 | 148 | from distutils.version import LooseVersion |
|
149 | 149 | try: |
|
150 | 150 | import readline |
|
151 | 151 | except ImportError: |
|
152 | 152 | try: |
|
153 | 153 | import pyreadline |
|
154 | 154 | vs = pyreadline.release.version |
|
155 | 155 | except (ImportError, AttributeError): |
|
156 | 156 | print_status('readline', "no (required for good interactive behavior)") |
|
157 | 157 | return False |
|
158 | 158 | if LooseVersion(vs).version >= [1,7,1]: |
|
159 | 159 | print_status('readline', "yes pyreadline-" + vs) |
|
160 | 160 | return True |
|
161 | 161 | else: |
|
162 | 162 | print_status('readline', "no pyreadline-%s < 1.7.1" % vs) |
|
163 | 163 | return False |
|
164 | 164 | else: |
|
165 | if sys.platform == 'darwin' and 'libedit' in readline.__doc__: | |
|
166 | print_status('readline', "no (libedit detected)") | |
|
167 | return False | |
|
165 | 168 | print_status('readline', "yes") |
|
166 | 169 | return True |
General Comments 0
You need to be logged in to leave comments.
Login now