Show More
@@ -1,262 +1,263 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | # -*- coding: utf-8 -*- |
|
2 | # -*- coding: utf-8 -*- | |
3 | """Setup script for IPython. |
|
3 | """Setup script for IPython. | |
4 |
|
4 | |||
5 | Under Posix environments it works like a typical setup.py script. |
|
5 | Under Posix environments it works like a typical setup.py script. | |
6 | Under Windows, the command sdist is not supported, since IPython |
|
6 | Under Windows, the command sdist is not supported, since IPython | |
7 | requires utilities which are not available under Windows.""" |
|
7 | requires utilities which are not available under Windows.""" | |
8 |
|
8 | |||
9 | #----------------------------------------------------------------------------- |
|
9 | #----------------------------------------------------------------------------- | |
10 | # Copyright (c) 2008-2010, IPython Development Team. |
|
10 | # Copyright (c) 2008-2010, IPython Development Team. | |
11 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> |
|
11 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> | |
12 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
12 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> | |
13 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
13 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> | |
14 | # |
|
14 | # | |
15 | # Distributed under the terms of the Modified BSD License. |
|
15 | # Distributed under the terms of the Modified BSD License. | |
16 | # |
|
16 | # | |
17 | # The full license is in the file COPYING.txt, distributed with this software. |
|
17 | # The full license is in the file COPYING.txt, distributed with this software. | |
18 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
19 |
|
19 | |||
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
21 | # Minimal Python version sanity check |
|
21 | # Minimal Python version sanity check | |
22 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
23 |
|
23 | |||
24 | import sys |
|
24 | import sys | |
25 |
|
25 | |||
26 | # This check is also made in IPython/__init__, don't forget to update both when |
|
26 | # This check is also made in IPython/__init__, don't forget to update both when | |
27 | # changing Python version requirements. |
|
27 | # changing Python version requirements. | |
28 | if sys.version[0:3] < '2.6': |
|
28 | if sys.version[0:3] < '2.6': | |
29 | error = """\ |
|
29 | error = """\ | |
30 | ERROR: 'IPython requires Python Version 2.6 or above.' |
|
30 | ERROR: 'IPython requires Python Version 2.6 or above.' | |
31 | Exiting.""" |
|
31 | Exiting.""" | |
32 | print >> sys.stderr, error |
|
32 | print >> sys.stderr, error | |
33 | sys.exit(1) |
|
33 | sys.exit(1) | |
34 |
|
34 | |||
35 | # At least we're on the python version we need, move on. |
|
35 | # At least we're on the python version we need, move on. | |
36 |
|
36 | |||
37 | #------------------------------------------------------------------------------- |
|
37 | #------------------------------------------------------------------------------- | |
38 | # Imports |
|
38 | # Imports | |
39 | #------------------------------------------------------------------------------- |
|
39 | #------------------------------------------------------------------------------- | |
40 |
|
40 | |||
41 | # Stdlib imports |
|
41 | # Stdlib imports | |
42 | import os |
|
42 | import os | |
43 | import shutil |
|
43 | import shutil | |
44 |
|
44 | |||
45 | from glob import glob |
|
45 | from glob import glob | |
46 |
|
46 | |||
47 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
47 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly | |
48 | # update it when the contents of directories change. |
|
48 | # update it when the contents of directories change. | |
49 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
49 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') | |
50 |
|
50 | |||
51 | from distutils.core import setup |
|
51 | from distutils.core import setup | |
52 |
|
52 | |||
53 | # Our own imports |
|
53 | # Our own imports | |
54 | from IPython.utils.path import target_update |
|
54 | from IPython.utils.path import target_update | |
55 |
|
55 | |||
56 | from setupbase import ( |
|
56 | from setupbase import ( | |
57 | setup_args, |
|
57 | setup_args, | |
58 | find_packages, |
|
58 | find_packages, | |
59 | find_package_data, |
|
59 | find_package_data, | |
60 | find_scripts, |
|
60 | find_scripts, | |
61 | find_data_files, |
|
61 | find_data_files, | |
62 | check_for_dependencies, |
|
62 | check_for_dependencies, | |
63 | record_commit_info, |
|
63 | record_commit_info, | |
64 | ) |
|
64 | ) | |
65 | from setupext.setupext import check_for_readline |
|
65 | from setupext import setupext | |
66 |
|
66 | |||
67 | isfile = os.path.isfile |
|
67 | isfile = os.path.isfile | |
68 | pjoin = os.path.join |
|
68 | pjoin = os.path.join | |
69 |
|
69 | |||
70 | #----------------------------------------------------------------------------- |
|
70 | #----------------------------------------------------------------------------- | |
71 | # Function definitions |
|
71 | # Function definitions | |
72 | #----------------------------------------------------------------------------- |
|
72 | #----------------------------------------------------------------------------- | |
73 |
|
73 | |||
74 | def cleanup(): |
|
74 | def cleanup(): | |
75 | """Clean up the junk left around by the build process""" |
|
75 | """Clean up the junk left around by the build process""" | |
76 | if "develop" not in sys.argv: |
|
76 | if "develop" not in sys.argv: | |
77 | try: |
|
77 | try: | |
78 | shutil.rmtree('ipython.egg-info') |
|
78 | shutil.rmtree('ipython.egg-info') | |
79 | except: |
|
79 | except: | |
80 | try: |
|
80 | try: | |
81 | os.unlink('ipython.egg-info') |
|
81 | os.unlink('ipython.egg-info') | |
82 | except: |
|
82 | except: | |
83 | pass |
|
83 | pass | |
84 |
|
84 | |||
85 | #------------------------------------------------------------------------------- |
|
85 | #------------------------------------------------------------------------------- | |
86 | # Handle OS specific things |
|
86 | # Handle OS specific things | |
87 | #------------------------------------------------------------------------------- |
|
87 | #------------------------------------------------------------------------------- | |
88 |
|
88 | |||
89 | if os.name == 'posix': |
|
89 | if os.name == 'posix': | |
90 | os_name = 'posix' |
|
90 | os_name = 'posix' | |
91 | elif os.name in ['nt','dos']: |
|
91 | elif os.name in ['nt','dos']: | |
92 | os_name = 'windows' |
|
92 | os_name = 'windows' | |
93 | else: |
|
93 | else: | |
94 | print 'Unsupported operating system:',os.name |
|
94 | print 'Unsupported operating system:',os.name | |
95 | sys.exit(1) |
|
95 | sys.exit(1) | |
96 |
|
96 | |||
97 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
97 | # Under Windows, 'sdist' has not been supported. Now that the docs build with | |
98 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
98 | # Sphinx it might work, but let's not turn it on until someone confirms that it | |
99 | # actually works. |
|
99 | # actually works. | |
100 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
100 | if os_name == 'windows' and 'sdist' in sys.argv: | |
101 | print 'The sdist command is not available under Windows. Exiting.' |
|
101 | print 'The sdist command is not available under Windows. Exiting.' | |
102 | sys.exit(1) |
|
102 | sys.exit(1) | |
103 |
|
103 | |||
104 | #------------------------------------------------------------------------------- |
|
104 | #------------------------------------------------------------------------------- | |
105 | # Things related to the IPython documentation |
|
105 | # Things related to the IPython documentation | |
106 | #------------------------------------------------------------------------------- |
|
106 | #------------------------------------------------------------------------------- | |
107 |
|
107 | |||
108 | # update the manuals when building a source dist |
|
108 | # update the manuals when building a source dist | |
109 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
109 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): | |
110 | import textwrap |
|
110 | import textwrap | |
111 |
|
111 | |||
112 | # List of things to be updated. Each entry is a triplet of args for |
|
112 | # List of things to be updated. Each entry is a triplet of args for | |
113 | # target_update() |
|
113 | # target_update() | |
114 | to_update = [ |
|
114 | to_update = [ | |
115 | # FIXME - Disabled for now: we need to redo an automatic way |
|
115 | # FIXME - Disabled for now: we need to redo an automatic way | |
116 | # of generating the magic info inside the rst. |
|
116 | # of generating the magic info inside the rst. | |
117 | #('docs/magic.tex', |
|
117 | #('docs/magic.tex', | |
118 | #['IPython/Magic.py'], |
|
118 | #['IPython/Magic.py'], | |
119 | #"cd doc && ./update_magic.sh" ), |
|
119 | #"cd doc && ./update_magic.sh" ), | |
120 |
|
120 | |||
121 | ('docs/man/ipcluster.1.gz', |
|
121 | ('docs/man/ipcluster.1.gz', | |
122 | ['docs/man/ipcluster.1'], |
|
122 | ['docs/man/ipcluster.1'], | |
123 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), |
|
123 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), | |
124 |
|
124 | |||
125 | ('docs/man/ipcontroller.1.gz', |
|
125 | ('docs/man/ipcontroller.1.gz', | |
126 | ['docs/man/ipcontroller.1'], |
|
126 | ['docs/man/ipcontroller.1'], | |
127 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), |
|
127 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), | |
128 |
|
128 | |||
129 | ('docs/man/ipengine.1.gz', |
|
129 | ('docs/man/ipengine.1.gz', | |
130 | ['docs/man/ipengine.1'], |
|
130 | ['docs/man/ipengine.1'], | |
131 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), |
|
131 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), | |
132 |
|
132 | |||
133 | ('docs/man/ipython.1.gz', |
|
133 | ('docs/man/ipython.1.gz', | |
134 | ['docs/man/ipython.1'], |
|
134 | ['docs/man/ipython.1'], | |
135 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
135 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), | |
136 |
|
136 | |||
137 | ('docs/man/ipython-wx.1.gz', |
|
137 | ('docs/man/ipython-wx.1.gz', | |
138 | ['docs/man/ipython-wx.1'], |
|
138 | ['docs/man/ipython-wx.1'], | |
139 | 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'), |
|
139 | 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'), | |
140 |
|
140 | |||
141 | ('docs/man/ipythonx.1.gz', |
|
141 | ('docs/man/ipythonx.1.gz', | |
142 | ['docs/man/ipythonx.1'], |
|
142 | ['docs/man/ipythonx.1'], | |
143 | 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'), |
|
143 | 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'), | |
144 |
|
144 | |||
145 | ('docs/man/irunner.1.gz', |
|
145 | ('docs/man/irunner.1.gz', | |
146 | ['docs/man/irunner.1'], |
|
146 | ['docs/man/irunner.1'], | |
147 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), |
|
147 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), | |
148 |
|
148 | |||
149 | ('docs/man/pycolor.1.gz', |
|
149 | ('docs/man/pycolor.1.gz', | |
150 | ['docs/man/pycolor.1'], |
|
150 | ['docs/man/pycolor.1'], | |
151 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), |
|
151 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), | |
152 | ] |
|
152 | ] | |
153 |
|
153 | |||
154 | # Only build the docs if sphinx is present |
|
154 | # Only build the docs if sphinx is present | |
155 | try: |
|
155 | try: | |
156 | import sphinx |
|
156 | import sphinx | |
157 | except ImportError: |
|
157 | except ImportError: | |
158 | pass |
|
158 | pass | |
159 | else: |
|
159 | else: | |
160 | # The Makefile calls the do_sphinx scripts to build html and pdf, so |
|
160 | # The Makefile calls the do_sphinx scripts to build html and pdf, so | |
161 | # just one target is enough to cover all manual generation |
|
161 | # just one target is enough to cover all manual generation | |
162 |
|
162 | |||
163 | # First, compute all the dependencies that can force us to rebuild the |
|
163 | # First, compute all the dependencies that can force us to rebuild the | |
164 | # docs. Start with the main release file that contains metadata |
|
164 | # docs. Start with the main release file that contains metadata | |
165 | docdeps = ['IPython/core/release.py'] |
|
165 | docdeps = ['IPython/core/release.py'] | |
166 | # Inculde all the reST sources |
|
166 | # Inculde all the reST sources | |
167 | pjoin = os.path.join |
|
167 | pjoin = os.path.join | |
168 | for dirpath,dirnames,filenames in os.walk('docs/source'): |
|
168 | for dirpath,dirnames,filenames in os.walk('docs/source'): | |
169 | if dirpath in ['_static','_templates']: |
|
169 | if dirpath in ['_static','_templates']: | |
170 | continue |
|
170 | continue | |
171 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
171 | docdeps += [ pjoin(dirpath,f) for f in filenames | |
172 | if f.endswith('.txt') ] |
|
172 | if f.endswith('.txt') ] | |
173 | # and the examples |
|
173 | # and the examples | |
174 | for dirpath,dirnames,filenames in os.walk('docs/example'): |
|
174 | for dirpath,dirnames,filenames in os.walk('docs/example'): | |
175 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
175 | docdeps += [ pjoin(dirpath,f) for f in filenames | |
176 | if not f.endswith('~') ] |
|
176 | if not f.endswith('~') ] | |
177 | # then, make them all dependencies for the main PDF (the html will get |
|
177 | # then, make them all dependencies for the main PDF (the html will get | |
178 | # auto-generated as well). |
|
178 | # auto-generated as well). | |
179 | to_update.append( |
|
179 | to_update.append( | |
180 | ('docs/dist/ipython.pdf', |
|
180 | ('docs/dist/ipython.pdf', | |
181 | docdeps, |
|
181 | docdeps, | |
182 | "cd docs && make dist") |
|
182 | "cd docs && make dist") | |
183 | ) |
|
183 | ) | |
184 |
|
184 | |||
185 | [ target_update(*t) for t in to_update ] |
|
185 | [ target_update(*t) for t in to_update ] | |
186 |
|
186 | |||
187 | #--------------------------------------------------------------------------- |
|
187 | #--------------------------------------------------------------------------- | |
188 | # Find all the packages, package data, and data_files |
|
188 | # Find all the packages, package data, and data_files | |
189 | #--------------------------------------------------------------------------- |
|
189 | #--------------------------------------------------------------------------- | |
190 |
|
190 | |||
191 | packages = find_packages() |
|
191 | packages = find_packages() | |
192 | package_data = find_package_data() |
|
192 | package_data = find_package_data() | |
193 | data_files = find_data_files() |
|
193 | data_files = find_data_files() | |
194 |
|
194 | |||
195 | #--------------------------------------------------------------------------- |
|
195 | #--------------------------------------------------------------------------- | |
196 | # Handle scripts, dependencies, and setuptools specific things |
|
196 | # Handle scripts, dependencies, and setuptools specific things | |
197 | #--------------------------------------------------------------------------- |
|
197 | #--------------------------------------------------------------------------- | |
198 |
|
198 | |||
199 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
199 | # For some commands, use setuptools. Note that we do NOT list install here! | |
200 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
200 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' | |
201 | if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm', |
|
201 | if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm', | |
202 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', |
|
202 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', | |
203 | 'build_sphinx', 'egg_info', 'easy_install', 'upload', |
|
203 | 'build_sphinx', 'egg_info', 'easy_install', 'upload', | |
204 | )).intersection(sys.argv)) > 0: |
|
204 | )).intersection(sys.argv)) > 0: | |
205 | import setuptools |
|
205 | import setuptools | |
206 |
|
206 | |||
207 | # This dict is used for passing extra arguments that are setuptools |
|
207 | # This dict is used for passing extra arguments that are setuptools | |
208 | # specific to setup |
|
208 | # specific to setup | |
209 | setuptools_extra_args = {} |
|
209 | setuptools_extra_args = {} | |
210 |
|
210 | |||
211 | if 'setuptools' in sys.modules: |
|
211 | if 'setuptools' in sys.modules: | |
212 | setuptools_extra_args['zip_safe'] = False |
|
212 | setuptools_extra_args['zip_safe'] = False | |
213 | setuptools_extra_args['entry_points'] = { |
|
213 | setuptools_extra_args['entry_points'] = { | |
214 | 'console_scripts': find_scripts(True) |
|
214 | 'console_scripts': find_scripts(True) | |
215 | } |
|
215 | } | |
216 | setup_args['extras_require'] = dict( |
|
216 | setup_args['extras_require'] = dict( | |
217 | parallel = 'pyzmq>=2.1.4', |
|
217 | parallel = 'pyzmq>=2.1.4', | |
218 | zmq = 'pyzmq>=2.0.10.1', |
|
218 | zmq = 'pyzmq>=2.0.10.1', | |
219 | doc='Sphinx>=0.3', |
|
219 | doc='Sphinx>=0.3', | |
220 | test='nose>=0.10.1', |
|
220 | test='nose>=0.10.1', | |
221 | ) |
|
221 | ) | |
222 | requires = setup_args.setdefault('install_requires', []) |
|
222 | requires = setup_args.setdefault('install_requires', []) | |
223 | if not check_for_readline(): |
|
223 | setupext.display_status = False | |
|
224 | if not setupext.check_for_readline(): | |||
224 | if sys.platform == 'darwin': |
|
225 | if sys.platform == 'darwin': | |
225 |
|
|
226 | requires.append('readline') | |
226 | elif sys.platform.startswith('win'): |
|
227 | elif sys.platform.startswith('win'): | |
227 | requires.append('pyreadline') |
|
228 | requires.append('pyreadline') | |
228 | else: |
|
229 | else: | |
229 | pass |
|
230 | pass | |
230 | # do we want to install readline here? |
|
231 | # do we want to install readline here? | |
231 |
|
232 | |||
232 | # Script to be run by the windows binary installer after the default setup |
|
233 | # Script to be run by the windows binary installer after the default setup | |
233 | # routine, to add shortcuts and similar windows-only things. Windows |
|
234 | # routine, to add shortcuts and similar windows-only things. Windows | |
234 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils |
|
235 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils | |
235 | # doesn't find them. |
|
236 | # doesn't find them. | |
236 | if 'bdist_wininst' in sys.argv: |
|
237 | if 'bdist_wininst' in sys.argv: | |
237 | if len(sys.argv) > 2 and \ |
|
238 | if len(sys.argv) > 2 and \ | |
238 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): |
|
239 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): | |
239 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." |
|
240 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." | |
240 | sys.exit(1) |
|
241 | sys.exit(1) | |
241 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] |
|
242 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] | |
242 | else: |
|
243 | else: | |
243 | # If we are running without setuptools, call this function which will |
|
244 | # If we are running without setuptools, call this function which will | |
244 | # check for dependencies an inform the user what is needed. This is |
|
245 | # check for dependencies an inform the user what is needed. This is | |
245 | # just to make life easy for users. |
|
246 | # just to make life easy for users. | |
246 | check_for_dependencies() |
|
247 | check_for_dependencies() | |
247 | setup_args['scripts'] = find_scripts(False) |
|
248 | setup_args['scripts'] = find_scripts(False) | |
248 |
|
249 | |||
249 | #--------------------------------------------------------------------------- |
|
250 | #--------------------------------------------------------------------------- | |
250 | # Do the actual setup now |
|
251 | # Do the actual setup now | |
251 | #--------------------------------------------------------------------------- |
|
252 | #--------------------------------------------------------------------------- | |
252 |
|
253 | |||
253 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython')} |
|
254 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython')} | |
254 | setup_args['packages'] = packages |
|
255 | setup_args['packages'] = packages | |
255 | setup_args['package_data'] = package_data |
|
256 | setup_args['package_data'] = package_data | |
256 | setup_args['data_files'] = data_files |
|
257 | setup_args['data_files'] = data_files | |
257 | setup_args.update(setuptools_extra_args) |
|
258 | setup_args.update(setuptools_extra_args) | |
258 |
|
259 | |||
259 |
|
260 | |||
260 | if __name__ == '__main__': |
|
261 | if __name__ == '__main__': | |
261 | setup(**setup_args) |
|
262 | setup(**setup_args) | |
262 | cleanup() |
|
263 | cleanup() |
@@ -1,157 +1,163 b'' | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 |
|
2 | |||
3 | __docformat__ = "restructuredtext en" |
|
3 | __docformat__ = "restructuredtext en" | |
4 |
|
4 | |||
5 | #------------------------------------------------------------------------------- |
|
5 | #------------------------------------------------------------------------------- | |
6 | # Copyright (C) 2008 The IPython Development Team |
|
6 | # Copyright (C) 2008 The IPython Development Team | |
7 | # |
|
7 | # | |
8 | # Distributed under the terms of the BSD License. The full license is in |
|
8 | # Distributed under the terms of the BSD License. The full license is in | |
9 | # the file COPYING, distributed as part of this software. |
|
9 | # the file COPYING, distributed as part of this software. | |
10 | #------------------------------------------------------------------------------- |
|
10 | #------------------------------------------------------------------------------- | |
11 |
|
11 | |||
12 | #------------------------------------------------------------------------------- |
|
12 | #------------------------------------------------------------------------------- | |
13 | # Imports |
|
13 | # Imports | |
14 | #------------------------------------------------------------------------------- |
|
14 | #------------------------------------------------------------------------------- | |
15 |
|
15 | |||
16 | import sys, os |
|
16 | import sys, os | |
17 | from textwrap import fill |
|
17 | from textwrap import fill | |
18 |
|
18 | |||
19 | display_status=True |
|
19 | display_status=True | |
20 |
|
20 | |||
21 | if display_status: |
|
21 | def check_display(f): | |
22 | def print_line(char='='): |
|
22 | """decorator to allow display methods to be muted by mod.display_status""" | |
23 | print char * 76 |
|
23 | def maybe_display(*args, **kwargs): | |
24 |
|
24 | if display_status: | ||
25 | def print_status(package, status): |
|
25 | return f(*args, **kwargs) | |
26 | initial_indent = "%22s: " % package |
|
26 | return maybe_display | |
27 | indent = ' ' * 24 |
|
27 | ||
28 | print fill(str(status), width=76, |
|
28 | @check_display | |
29 | initial_indent=initial_indent, |
|
29 | def print_line(char='='): | |
30 | subsequent_indent=indent) |
|
30 | print char * 76 | |
31 |
|
31 | |||
32 | def print_message(message): |
|
32 | @check_display | |
33 | indent = ' ' * 24 + "* " |
|
33 | def print_status(package, status): | |
34 | print fill(str(message), width=76, |
|
34 | initial_indent = "%22s: " % package | |
35 | initial_indent=indent, |
|
35 | indent = ' ' * 24 | |
36 | subsequent_indent=indent) |
|
36 | print fill(str(status), width=76, | |
37 |
|
37 | initial_indent=initial_indent, | ||
38 | def print_raw(section): |
|
38 | subsequent_indent=indent) | |
39 | print section |
|
39 | ||
40 | else: |
|
40 | @check_display | |
41 | def print_line(*args, **kwargs): |
|
41 | def print_message(message): | |
42 | pass |
|
42 | indent = ' ' * 24 + "* " | |
43 | print_status = print_message = print_raw = print_line |
|
43 | print fill(str(message), width=76, | |
|
44 | initial_indent=indent, | |||
|
45 | subsequent_indent=indent) | |||
|
46 | ||||
|
47 | @check_display | |||
|
48 | def print_raw(section): | |||
|
49 | print section | |||
44 |
|
50 | |||
45 | #------------------------------------------------------------------------------- |
|
51 | #------------------------------------------------------------------------------- | |
46 | # Tests for specific packages |
|
52 | # Tests for specific packages | |
47 | #------------------------------------------------------------------------------- |
|
53 | #------------------------------------------------------------------------------- | |
48 |
|
54 | |||
49 | def check_for_ipython(): |
|
55 | def check_for_ipython(): | |
50 | try: |
|
56 | try: | |
51 | import IPython |
|
57 | import IPython | |
52 | except ImportError: |
|
58 | except ImportError: | |
53 | print_status("IPython", "Not found") |
|
59 | print_status("IPython", "Not found") | |
54 | return False |
|
60 | return False | |
55 | else: |
|
61 | else: | |
56 | print_status("IPython", IPython.__version__) |
|
62 | print_status("IPython", IPython.__version__) | |
57 | return True |
|
63 | return True | |
58 |
|
64 | |||
59 | def check_for_sphinx(): |
|
65 | def check_for_sphinx(): | |
60 | try: |
|
66 | try: | |
61 | import sphinx |
|
67 | import sphinx | |
62 | except ImportError: |
|
68 | except ImportError: | |
63 | print_status('sphinx', "Not found (required for building documentation)") |
|
69 | print_status('sphinx', "Not found (required for building documentation)") | |
64 | return False |
|
70 | return False | |
65 | else: |
|
71 | else: | |
66 | print_status('sphinx', sphinx.__version__) |
|
72 | print_status('sphinx', sphinx.__version__) | |
67 | return True |
|
73 | return True | |
68 |
|
74 | |||
69 | def check_for_pygments(): |
|
75 | def check_for_pygments(): | |
70 | try: |
|
76 | try: | |
71 | import pygments |
|
77 | import pygments | |
72 | except ImportError: |
|
78 | except ImportError: | |
73 | print_status('pygments', "Not found (required for syntax highlighting documentation)") |
|
79 | print_status('pygments', "Not found (required for syntax highlighting documentation)") | |
74 | return False |
|
80 | return False | |
75 | else: |
|
81 | else: | |
76 | print_status('pygments', pygments.__version__) |
|
82 | print_status('pygments', pygments.__version__) | |
77 | return True |
|
83 | return True | |
78 |
|
84 | |||
79 | def check_for_nose(): |
|
85 | def check_for_nose(): | |
80 | try: |
|
86 | try: | |
81 | import nose |
|
87 | import nose | |
82 | except ImportError: |
|
88 | except ImportError: | |
83 | print_status('nose', "Not found (required for running the test suite)") |
|
89 | print_status('nose', "Not found (required for running the test suite)") | |
84 | return False |
|
90 | return False | |
85 | else: |
|
91 | else: | |
86 | print_status('nose', nose.__version__) |
|
92 | print_status('nose', nose.__version__) | |
87 | return True |
|
93 | return True | |
88 |
|
94 | |||
89 | def check_for_pexpect(): |
|
95 | def check_for_pexpect(): | |
90 | try: |
|
96 | try: | |
91 | import pexpect |
|
97 | import pexpect | |
92 | except ImportError: |
|
98 | except ImportError: | |
93 | print_status("pexpect", "no (required for running standalone doctests)") |
|
99 | print_status("pexpect", "no (required for running standalone doctests)") | |
94 | return False |
|
100 | return False | |
95 | else: |
|
101 | else: | |
96 | print_status("pexpect", pexpect.__version__) |
|
102 | print_status("pexpect", pexpect.__version__) | |
97 | return True |
|
103 | return True | |
98 |
|
104 | |||
99 | def check_for_httplib2(): |
|
105 | def check_for_httplib2(): | |
100 | try: |
|
106 | try: | |
101 | import httplib2 |
|
107 | import httplib2 | |
102 | except ImportError: |
|
108 | except ImportError: | |
103 | print_status("httplib2", "no (required for blocking http clients)") |
|
109 | print_status("httplib2", "no (required for blocking http clients)") | |
104 | return False |
|
110 | return False | |
105 | else: |
|
111 | else: | |
106 | print_status("httplib2","yes") |
|
112 | print_status("httplib2","yes") | |
107 | return True |
|
113 | return True | |
108 |
|
114 | |||
109 | def check_for_sqlalchemy(): |
|
115 | def check_for_sqlalchemy(): | |
110 | try: |
|
116 | try: | |
111 | import sqlalchemy |
|
117 | import sqlalchemy | |
112 | except ImportError: |
|
118 | except ImportError: | |
113 | print_status("sqlalchemy", "no (required for the ipython1 notebook)") |
|
119 | print_status("sqlalchemy", "no (required for the ipython1 notebook)") | |
114 | return False |
|
120 | return False | |
115 | else: |
|
121 | else: | |
116 | print_status("sqlalchemy","yes") |
|
122 | print_status("sqlalchemy","yes") | |
117 | return True |
|
123 | return True | |
118 |
|
124 | |||
119 | def check_for_simplejson(): |
|
125 | def check_for_simplejson(): | |
120 | try: |
|
126 | try: | |
121 | import simplejson |
|
127 | import simplejson | |
122 | except ImportError: |
|
128 | except ImportError: | |
123 | print_status("simplejson", "no (required for the ipython1 notebook)") |
|
129 | print_status("simplejson", "no (required for the ipython1 notebook)") | |
124 | return False |
|
130 | return False | |
125 | else: |
|
131 | else: | |
126 | print_status("simplejson","yes") |
|
132 | print_status("simplejson","yes") | |
127 | return True |
|
133 | return True | |
128 |
|
134 | |||
129 | def check_for_pyzmq(): |
|
135 | def check_for_pyzmq(): | |
130 | try: |
|
136 | try: | |
131 | import zmq |
|
137 | import zmq | |
132 | except ImportError: |
|
138 | except ImportError: | |
133 | print_status('pyzmq', "no (required for qtconsole and parallel computing capabilities)") |
|
139 | print_status('pyzmq', "no (required for qtconsole and parallel computing capabilities)") | |
134 | return False |
|
140 | return False | |
135 | else: |
|
141 | else: | |
136 | if zmq.__version__ < '2.0.10': |
|
142 | if zmq.__version__ < '2.0.10': | |
137 | print_status('pyzmq', "no (require >= 2.0.10 for qtconsole and parallel computing capabilities)") |
|
143 | print_status('pyzmq', "no (require >= 2.0.10 for qtconsole and parallel computing capabilities)") | |
138 |
|
144 | |||
139 | else: |
|
145 | else: | |
140 | print_status("pyzmq", zmq.__version__) |
|
146 | print_status("pyzmq", zmq.__version__) | |
141 | return True |
|
147 | return True | |
142 |
|
148 | |||
143 | def check_for_readline(): |
|
149 | def check_for_readline(): | |
144 | try: |
|
150 | try: | |
145 | import readline |
|
151 | import readline | |
146 | except ImportError: |
|
152 | except ImportError: | |
147 | try: |
|
153 | try: | |
148 | import pyreadline |
|
154 | import pyreadline | |
149 | except ImportError: |
|
155 | except ImportError: | |
150 | print_status('readline', "no (required for good interactive behavior)") |
|
156 | print_status('readline', "no (required for good interactive behavior)") | |
151 | return False |
|
157 | return False | |
152 | else: |
|
158 | else: | |
153 | print_status('readline', "yes pyreadline-"+pyreadline.release.version) |
|
159 | print_status('readline', "yes pyreadline-"+pyreadline.release.version) | |
154 | return True |
|
160 | return True | |
155 | else: |
|
161 | else: | |
156 | print_status('readline', "yes") |
|
162 | print_status('readline', "yes") | |
157 | return True |
|
163 | return True |
General Comments 0
You need to be logged in to leave comments.
Login now