Show More
@@ -1,251 +1,251 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # -*- coding: utf-8 -*- |
|
3 | 3 | """Setup script for IPython. |
|
4 | 4 | |
|
5 | 5 | Under Posix environments it works like a typical setup.py script. |
|
6 | 6 | Under Windows, the command sdist is not supported, since IPython |
|
7 | 7 | requires utilities which are not available under Windows.""" |
|
8 | 8 | |
|
9 | 9 | #------------------------------------------------------------------------------- |
|
10 | 10 | # Copyright (C) 2008 The IPython Development Team |
|
11 | 11 | # |
|
12 | 12 | # Distributed under the terms of the BSD License. The full license is in |
|
13 | 13 | # the file COPYING, distributed as part of this software. |
|
14 | 14 | #------------------------------------------------------------------------------- |
|
15 | 15 | |
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | # Minimal Python version sanity check |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | import sys |
|
21 | 21 | |
|
22 | 22 | # This check is also made in IPython/__init__, don't forget to update both when |
|
23 | 23 | # changing Python version requirements. |
|
24 | 24 | if sys.version[0:3] < '2.5': |
|
25 | 25 | error = """\ |
|
26 | 26 | ERROR: 'IPython requires Python Version 2.5 or above.' |
|
27 | 27 | Exiting.""" |
|
28 | 28 | print >> sys.stderr, error |
|
29 | 29 | sys.exit(1) |
|
30 | 30 | |
|
31 | 31 | # At least we're on Python 2.5 or newer, move on. |
|
32 | 32 | |
|
33 | 33 | #------------------------------------------------------------------------------- |
|
34 | 34 | # Imports |
|
35 | 35 | #------------------------------------------------------------------------------- |
|
36 | 36 | |
|
37 | 37 | # Stdlib imports |
|
38 | 38 | import os |
|
39 | 39 | import shutil |
|
40 | 40 | |
|
41 | 41 | from glob import glob |
|
42 | 42 | |
|
43 | 43 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
44 | 44 | # update it when the contents of directories change. |
|
45 | 45 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
46 | 46 | |
|
47 | 47 | from distutils.core import setup |
|
48 | 48 | |
|
49 | 49 | # Our own imports |
|
50 | 50 | from IPython.utils.path import target_update |
|
51 | 51 | |
|
52 | 52 | from setupbase import ( |
|
53 | 53 | setup_args, |
|
54 | 54 | find_packages, |
|
55 | 55 | find_package_data, |
|
56 | 56 | find_scripts, |
|
57 | 57 | find_data_files, |
|
58 | 58 | check_for_dependencies |
|
59 | 59 | ) |
|
60 | 60 | |
|
61 | 61 | isfile = os.path.isfile |
|
62 | 62 | pjoin = os.path.join |
|
63 | 63 | |
|
64 | 64 | #----------------------------------------------------------------------------- |
|
65 | 65 | # Function definitions |
|
66 | 66 | #----------------------------------------------------------------------------- |
|
67 | 67 | |
|
68 | 68 | def cleanup(): |
|
69 | 69 | """Clean up the junk left around by the build process""" |
|
70 | 70 | if "develop" not in sys.argv: |
|
71 | 71 | try: |
|
72 | 72 | shutil.rmtree('ipython.egg-info') |
|
73 | 73 | except: |
|
74 | 74 | try: |
|
75 | 75 | os.unlink('ipython.egg-info') |
|
76 | 76 | except: |
|
77 | 77 | pass |
|
78 | 78 | |
|
79 | 79 | #------------------------------------------------------------------------------- |
|
80 | 80 | # Handle OS specific things |
|
81 | 81 | #------------------------------------------------------------------------------- |
|
82 | 82 | |
|
83 | 83 | if os.name == 'posix': |
|
84 | 84 | os_name = 'posix' |
|
85 | 85 | elif os.name in ['nt','dos']: |
|
86 | 86 | os_name = 'windows' |
|
87 | 87 | else: |
|
88 | 88 | print 'Unsupported operating system:',os.name |
|
89 | 89 | sys.exit(1) |
|
90 | 90 | |
|
91 | 91 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
92 | 92 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
93 | 93 | # actually works. |
|
94 | 94 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
95 | 95 | print 'The sdist command is not available under Windows. Exiting.' |
|
96 | 96 | sys.exit(1) |
|
97 | 97 | |
|
98 | 98 | #------------------------------------------------------------------------------- |
|
99 | 99 | # Things related to the IPython documentation |
|
100 | 100 | #------------------------------------------------------------------------------- |
|
101 | 101 | |
|
102 | 102 | # update the manuals when building a source dist |
|
103 | 103 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
104 | 104 | import textwrap |
|
105 | 105 | |
|
106 | 106 | # List of things to be updated. Each entry is a triplet of args for |
|
107 | 107 | # target_update() |
|
108 | 108 | to_update = [ |
|
109 | 109 | # FIXME - Disabled for now: we need to redo an automatic way |
|
110 | 110 | # of generating the magic info inside the rst. |
|
111 | 111 | #('docs/magic.tex', |
|
112 | 112 | #['IPython/Magic.py'], |
|
113 | 113 | #"cd doc && ./update_magic.sh" ), |
|
114 | 114 | |
|
115 | 115 | ('docs/man/ipcluster.1.gz', |
|
116 | 116 | ['docs/man/ipcluster.1'], |
|
117 | 117 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), |
|
118 | 118 | |
|
119 | 119 | ('docs/man/ipcontroller.1.gz', |
|
120 | 120 | ['docs/man/ipcontroller.1'], |
|
121 | 121 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), |
|
122 | 122 | |
|
123 | 123 | ('docs/man/ipengine.1.gz', |
|
124 | 124 | ['docs/man/ipengine.1'], |
|
125 | 125 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), |
|
126 | 126 | |
|
127 | 127 | ('docs/man/ipython.1.gz', |
|
128 | 128 | ['docs/man/ipython.1'], |
|
129 | 129 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
130 | 130 | |
|
131 | 131 | ('docs/man/ipython-wx.1.gz', |
|
132 | 132 | ['docs/man/ipython-wx.1'], |
|
133 | 133 | 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'), |
|
134 | 134 | |
|
135 | 135 | ('docs/man/ipythonx.1.gz', |
|
136 | 136 | ['docs/man/ipythonx.1'], |
|
137 | 137 | 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'), |
|
138 | 138 | |
|
139 | 139 | ('docs/man/irunner.1.gz', |
|
140 | 140 | ['docs/man/irunner.1'], |
|
141 | 141 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), |
|
142 | 142 | |
|
143 | 143 | ('docs/man/pycolor.1.gz', |
|
144 | 144 | ['docs/man/pycolor.1'], |
|
145 | 145 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), |
|
146 | 146 | ] |
|
147 | 147 | |
|
148 | 148 | # Only build the docs if sphinx is present |
|
149 | 149 | try: |
|
150 | 150 | import sphinx |
|
151 | 151 | except ImportError: |
|
152 | 152 | pass |
|
153 | 153 | else: |
|
154 | 154 | # The Makefile calls the do_sphinx scripts to build html and pdf, so |
|
155 | 155 | # just one target is enough to cover all manual generation |
|
156 | 156 | |
|
157 | 157 | # First, compute all the dependencies that can force us to rebuild the |
|
158 | 158 | # docs. Start with the main release file that contains metadata |
|
159 | 159 | docdeps = ['IPython/core/release.py'] |
|
160 | 160 | # Inculde all the reST sources |
|
161 | 161 | pjoin = os.path.join |
|
162 | 162 | for dirpath,dirnames,filenames in os.walk('docs/source'): |
|
163 | 163 | if dirpath in ['_static','_templates']: |
|
164 | 164 | continue |
|
165 | 165 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
166 | 166 | if f.endswith('.txt') ] |
|
167 | 167 | # and the examples |
|
168 | 168 | for dirpath,dirnames,filenames in os.walk('docs/example'): |
|
169 | 169 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
170 | 170 | if not f.endswith('~') ] |
|
171 | 171 | # then, make them all dependencies for the main PDF (the html will get |
|
172 | 172 | # auto-generated as well). |
|
173 | 173 | to_update.append( |
|
174 | 174 | ('docs/dist/ipython.pdf', |
|
175 | 175 | docdeps, |
|
176 | 176 | "cd docs && make dist") |
|
177 | 177 | ) |
|
178 | 178 | |
|
179 | 179 | [ target_update(*t) for t in to_update ] |
|
180 | 180 | |
|
181 | 181 | #--------------------------------------------------------------------------- |
|
182 | 182 | # Find all the packages, package data, scripts and data_files |
|
183 | 183 | #--------------------------------------------------------------------------- |
|
184 | 184 | |
|
185 | 185 | packages = find_packages() |
|
186 | 186 | package_data = find_package_data() |
|
187 | 187 | scripts = find_scripts() |
|
188 | 188 | data_files = find_data_files() |
|
189 | 189 | |
|
190 | 190 | #--------------------------------------------------------------------------- |
|
191 | 191 | # Handle dependencies and setuptools specific things |
|
192 | 192 | #--------------------------------------------------------------------------- |
|
193 | 193 | |
|
194 | 194 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
195 | 195 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
196 | 196 | if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm', |
|
197 | 197 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', |
|
198 | 198 | 'build_sphinx', 'egg_info', 'easy_install', 'upload', |
|
199 | 199 | )).intersection(sys.argv)) > 0: |
|
200 | 200 | import setuptools |
|
201 | 201 | |
|
202 | 202 | # This dict is used for passing extra arguments that are setuptools |
|
203 | 203 | # specific to setup |
|
204 | 204 | setuptools_extra_args = {} |
|
205 | 205 | |
|
206 | 206 | if 'setuptools' in sys.modules: |
|
207 | 207 | setuptools_extra_args['zip_safe'] = False |
|
208 | 208 | setuptools_extra_args['entry_points'] = { |
|
209 | 209 | 'console_scripts': [ |
|
210 | 210 | 'ipython = IPython.frontend.terminal.ipapp:launch_new_instance', |
|
211 | 'ipythonqt = IPython.frontend.qt.console.ipythonqt:main', | |
|
211 | 'ipython-qtconsole = IPython.frontend.qt.console.ipythonqt:main', | |
|
212 | 212 | 'pycolor = IPython.utils.PyColorize:main', |
|
213 | 213 | 'ipcontroller = IPython.kernel.ipcontrollerapp:launch_new_instance', |
|
214 | 214 | 'ipengine = IPython.kernel.ipengineapp:launch_new_instance', |
|
215 | 215 | 'ipcluster = IPython.kernel.ipclusterapp:launch_new_instance', |
|
216 | 216 | 'iptest = IPython.testing.iptest:main', |
|
217 | 217 | 'irunner = IPython.lib.irunner:main' |
|
218 | 218 | ] |
|
219 | 219 | } |
|
220 | 220 | setup_args['extras_require'] = dict( |
|
221 | 221 | kernel = [ |
|
222 | 222 | 'zope.interface>=3.4.1', |
|
223 | 223 | 'Twisted>=8.0.1', |
|
224 | 224 | 'foolscap>=0.2.6' |
|
225 | 225 | ], |
|
226 | 226 | doc='Sphinx>=0.3', |
|
227 | 227 | test='nose>=0.10.1', |
|
228 | 228 | security='pyOpenSSL>=0.6' |
|
229 | 229 | ) |
|
230 | 230 | # Allow setuptools to handle the scripts |
|
231 | 231 | scripts = [] |
|
232 | 232 | else: |
|
233 | 233 | # If we are running without setuptools, call this function which will |
|
234 | 234 | # check for dependencies an inform the user what is needed. This is |
|
235 | 235 | # just to make life easy for users. |
|
236 | 236 | check_for_dependencies() |
|
237 | 237 | |
|
238 | 238 | #--------------------------------------------------------------------------- |
|
239 | 239 | # Do the actual setup now |
|
240 | 240 | #--------------------------------------------------------------------------- |
|
241 | 241 | |
|
242 | 242 | setup_args['packages'] = packages |
|
243 | 243 | setup_args['package_data'] = package_data |
|
244 | 244 | setup_args['scripts'] = scripts |
|
245 | 245 | setup_args['data_files'] = data_files |
|
246 | 246 | setup_args.update(setuptools_extra_args) |
|
247 | 247 | |
|
248 | 248 | |
|
249 | 249 | if __name__ == '__main__': |
|
250 | 250 | setup(**setup_args) |
|
251 | 251 | cleanup() |
General Comments 0
You need to be logged in to leave comments.
Login now