Show More
@@ -1,349 +1,349 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-2011, IPython Development Team. |
|
11 | 11 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> |
|
12 | 12 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
13 | 13 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
14 | 14 | # |
|
15 | 15 | # Distributed under the terms of the Modified BSD License. |
|
16 | 16 | # |
|
17 | 17 | # The full license is in the file COPYING.rst, distributed with this software. |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | # Minimal Python version sanity check |
|
22 | 22 | #----------------------------------------------------------------------------- |
|
23 | 23 | from __future__ import print_function |
|
24 | 24 | |
|
25 | 25 | import sys |
|
26 | 26 | |
|
27 | 27 | # This check is also made in IPython/__init__, don't forget to update both when |
|
28 | 28 | # changing Python version requirements. |
|
29 | 29 | v = sys.version_info |
|
30 | 30 | if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)): |
|
31 | 31 | error = "ERROR: IPython requires Python version 2.7 or 3.3 or above." |
|
32 | 32 | print(error, file=sys.stderr) |
|
33 | 33 | sys.exit(1) |
|
34 | 34 | |
|
35 | 35 | PY3 = (sys.version_info[0] >= 3) |
|
36 | 36 | |
|
37 | 37 | # At least we're on the python version we need, move on. |
|
38 | 38 | |
|
39 | 39 | #------------------------------------------------------------------------------- |
|
40 | 40 | # Imports |
|
41 | 41 | #------------------------------------------------------------------------------- |
|
42 | 42 | |
|
43 | 43 | # Stdlib imports |
|
44 | 44 | import os |
|
45 | 45 | import shutil |
|
46 | 46 | |
|
47 | 47 | from glob import glob |
|
48 | 48 | |
|
49 | 49 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
50 | 50 | # update it when the contents of directories change. |
|
51 | 51 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
52 | 52 | |
|
53 | 53 | from distutils.core import setup |
|
54 | 54 | |
|
55 | 55 | # Our own imports |
|
56 | 56 | from setupbase import target_update |
|
57 | 57 | |
|
58 | 58 | from setupbase import ( |
|
59 | 59 | setup_args, |
|
60 | 60 | find_packages, |
|
61 | 61 | find_package_data, |
|
62 | 62 | check_package_data_first, |
|
63 | 63 | find_entry_points, |
|
64 | 64 | build_scripts_entrypt, |
|
65 | 65 | find_data_files, |
|
66 | 66 | check_for_dependencies, |
|
67 | 67 | git_prebuild, |
|
68 | 68 | check_submodule_status, |
|
69 | 69 | update_submodules, |
|
70 | 70 | require_submodules, |
|
71 | 71 | UpdateSubmodules, |
|
72 | 72 | get_bdist_wheel, |
|
73 | 73 | CompileCSS, |
|
74 | 74 | JavascriptVersion, |
|
75 | 75 | css_js_prerelease, |
|
76 | 76 | install_symlinked, |
|
77 | 77 | install_lib_symlink, |
|
78 | 78 | install_scripts_for_symlink, |
|
79 | 79 | unsymlink, |
|
80 | 80 | ) |
|
81 | 81 | from setupext import setupext |
|
82 | 82 | |
|
83 | 83 | isfile = os.path.isfile |
|
84 | 84 | pjoin = os.path.join |
|
85 | 85 | |
|
86 | 86 | #----------------------------------------------------------------------------- |
|
87 | 87 | # Function definitions |
|
88 | 88 | #----------------------------------------------------------------------------- |
|
89 | 89 | |
|
90 | 90 | def cleanup(): |
|
91 | 91 | """Clean up the junk left around by the build process""" |
|
92 | 92 | if "develop" not in sys.argv and "egg_info" not in sys.argv: |
|
93 | 93 | try: |
|
94 | 94 | shutil.rmtree('ipython.egg-info') |
|
95 | 95 | except: |
|
96 | 96 | try: |
|
97 | 97 | os.unlink('ipython.egg-info') |
|
98 | 98 | except: |
|
99 | 99 | pass |
|
100 | 100 | |
|
101 | 101 | #------------------------------------------------------------------------------- |
|
102 | 102 | # Handle OS specific things |
|
103 | 103 | #------------------------------------------------------------------------------- |
|
104 | 104 | |
|
105 | 105 | if os.name in ('nt','dos'): |
|
106 | 106 | os_name = 'windows' |
|
107 | 107 | else: |
|
108 | 108 | os_name = os.name |
|
109 | 109 | |
|
110 | 110 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
111 | 111 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
112 | 112 | # actually works. |
|
113 | 113 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
114 | 114 | print('The sdist command is not available under Windows. Exiting.') |
|
115 | 115 | sys.exit(1) |
|
116 | 116 | |
|
117 | 117 | #------------------------------------------------------------------------------- |
|
118 | 118 | # Make sure we aren't trying to run without submodules |
|
119 | 119 | #------------------------------------------------------------------------------- |
|
120 | 120 | here = os.path.abspath(os.path.dirname(__file__)) |
|
121 | 121 | |
|
122 | 122 | def require_clean_submodules(): |
|
123 | 123 | """Check on git submodules before distutils can do anything |
|
124 | 124 | |
|
125 | 125 | Since distutils cannot be trusted to update the tree |
|
126 | 126 | after everything has been set in motion, |
|
127 | 127 | this is not a distutils command. |
|
128 | 128 | """ |
|
129 | 129 | # PACKAGERS: Add a return here to skip checks for git submodules |
|
130 | 130 | |
|
131 | 131 | # don't do anything if nothing is actually supposed to happen |
|
132 | 132 | for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'): |
|
133 | 133 | if do_nothing in sys.argv: |
|
134 | 134 | return |
|
135 | 135 | |
|
136 | 136 | status = check_submodule_status(here) |
|
137 | 137 | |
|
138 | 138 | if status == "missing": |
|
139 | 139 | print("checking out submodules for the first time") |
|
140 | 140 | update_submodules(here) |
|
141 | 141 | elif status == "unclean": |
|
142 | 142 | print('\n'.join([ |
|
143 | 143 | "Cannot build / install IPython with unclean submodules", |
|
144 | 144 | "Please update submodules with", |
|
145 | 145 | " python setup.py submodule", |
|
146 | 146 | "or", |
|
147 | 147 | " git submodule update", |
|
148 | 148 | "or commit any submodule changes you have made." |
|
149 | 149 | ])) |
|
150 | 150 | sys.exit(1) |
|
151 | 151 | |
|
152 | 152 | require_clean_submodules() |
|
153 | 153 | |
|
154 | 154 | #------------------------------------------------------------------------------- |
|
155 | 155 | # Things related to the IPython documentation |
|
156 | 156 | #------------------------------------------------------------------------------- |
|
157 | 157 | |
|
158 | 158 | # update the manuals when building a source dist |
|
159 | 159 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
160 | 160 | |
|
161 | 161 | # List of things to be updated. Each entry is a triplet of args for |
|
162 | 162 | # target_update() |
|
163 | 163 | to_update = [ |
|
164 | 164 | # FIXME - Disabled for now: we need to redo an automatic way |
|
165 | 165 | # of generating the magic info inside the rst. |
|
166 | 166 | #('docs/magic.tex', |
|
167 | 167 | #['IPython/Magic.py'], |
|
168 | 168 | #"cd doc && ./update_magic.sh" ), |
|
169 | 169 | |
|
170 | 170 | ('docs/man/ipcluster.1.gz', |
|
171 | 171 | ['docs/man/ipcluster.1'], |
|
172 | 172 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), |
|
173 | 173 | |
|
174 | 174 | ('docs/man/ipcontroller.1.gz', |
|
175 | 175 | ['docs/man/ipcontroller.1'], |
|
176 | 176 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), |
|
177 | 177 | |
|
178 | 178 | ('docs/man/ipengine.1.gz', |
|
179 | 179 | ['docs/man/ipengine.1'], |
|
180 | 180 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), |
|
181 | 181 | |
|
182 | 182 | ('docs/man/ipython.1.gz', |
|
183 | 183 | ['docs/man/ipython.1'], |
|
184 | 184 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
185 | 185 | |
|
186 | 186 | ] |
|
187 | 187 | |
|
188 | 188 | |
|
189 | 189 | [ target_update(*t) for t in to_update ] |
|
190 | 190 | |
|
191 | 191 | #--------------------------------------------------------------------------- |
|
192 | 192 | # Find all the packages, package data, and data_files |
|
193 | 193 | #--------------------------------------------------------------------------- |
|
194 | 194 | |
|
195 | 195 | packages = find_packages() |
|
196 | 196 | package_data = find_package_data() |
|
197 | 197 | |
|
198 | 198 | data_files = find_data_files() |
|
199 | 199 | |
|
200 | 200 | setup_args['packages'] = packages |
|
201 | 201 | setup_args['package_data'] = package_data |
|
202 | 202 | setup_args['data_files'] = data_files |
|
203 | 203 | |
|
204 | 204 | #--------------------------------------------------------------------------- |
|
205 | 205 | # custom distutils commands |
|
206 | 206 | #--------------------------------------------------------------------------- |
|
207 | 207 | # imports here, so they are after setuptools import if there was one |
|
208 | 208 | from distutils.command.sdist import sdist |
|
209 | 209 | from distutils.command.upload import upload |
|
210 | 210 | |
|
211 | 211 | class UploadWindowsInstallers(upload): |
|
212 | 212 | |
|
213 | 213 | description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)" |
|
214 | 214 | user_options = upload.user_options + [ |
|
215 | 215 | ('files=', 'f', 'exe file (or glob) to upload') |
|
216 | 216 | ] |
|
217 | 217 | def initialize_options(self): |
|
218 | 218 | upload.initialize_options(self) |
|
219 | 219 | meta = self.distribution.metadata |
|
220 | 220 | base = '{name}-{version}'.format( |
|
221 | 221 | name=meta.get_name(), |
|
222 | 222 | version=meta.get_version() |
|
223 | 223 | ) |
|
224 | 224 | self.files = os.path.join('dist', '%s.*.exe' % base) |
|
225 | 225 | |
|
226 | 226 | def run(self): |
|
227 | 227 | for dist_file in glob(self.files): |
|
228 | 228 | self.upload_file('bdist_wininst', 'any', dist_file) |
|
229 | 229 | |
|
230 | 230 | setup_args['cmdclass'] = { |
|
231 | 231 | 'build_py': css_js_prerelease( |
|
232 | 232 | check_package_data_first(git_prebuild('IPython')), |
|
233 | 233 | strict=False), |
|
234 | 234 | 'sdist' : css_js_prerelease(git_prebuild('IPython', sdist)), |
|
235 | 235 | 'upload_wininst' : UploadWindowsInstallers, |
|
236 | 236 | 'submodule' : UpdateSubmodules, |
|
237 | 237 | 'css' : CompileCSS, |
|
238 | 238 | 'symlink': install_symlinked, |
|
239 | 239 | 'install_lib_symlink': install_lib_symlink, |
|
240 | 240 | 'install_scripts_sym': install_scripts_for_symlink, |
|
241 | 241 | 'unsymlink': unsymlink, |
|
242 | 242 | 'jsversion' : JavascriptVersion, |
|
243 | 243 | } |
|
244 | 244 | |
|
245 | 245 | #--------------------------------------------------------------------------- |
|
246 | 246 | # Handle scripts, dependencies, and setuptools specific things |
|
247 | 247 | #--------------------------------------------------------------------------- |
|
248 | 248 | |
|
249 | 249 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
250 | 250 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
251 | 251 | needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm', |
|
252 | 252 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel', |
|
253 | 253 | 'egg_info', 'easy_install', 'upload', 'install_egg_info', |
|
254 | 254 | )) |
|
255 | 255 | |
|
256 | 256 | if len(needs_setuptools.intersection(sys.argv)) > 0: |
|
257 | 257 | import setuptools |
|
258 | 258 | |
|
259 | 259 | # This dict is used for passing extra arguments that are setuptools |
|
260 | 260 | # specific to setup |
|
261 | 261 | setuptools_extra_args = {} |
|
262 | 262 | |
|
263 | 263 | # setuptools requirements |
|
264 | 264 | |
|
265 | 265 | extras_require = dict( |
|
266 | 266 | parallel = ['pyzmq>=2.1.11'], |
|
267 | 267 | qtconsole = ['pyzmq>=2.1.11', 'pygments'], |
|
268 | 268 | zmq = ['pyzmq>=2.1.11'], |
|
269 | 269 | doc = ['Sphinx>=1.1', 'numpydoc'], |
|
270 | 270 | test = ['nose>=0.10.1', 'requests'], |
|
271 | 271 | terminal = [], |
|
272 | 272 | nbformat = ['jsonschema>=2.0'], |
|
273 | 273 | notebook = ['tornado>=4.0', 'pyzmq>=2.1.11', 'jinja2', 'pygments', 'mistune>=0.3.1'], |
|
274 | 274 | nbconvert = ['pygments', 'jinja2', 'mistune>=0.3.1'] |
|
275 | 275 | ) |
|
276 | 276 | |
|
277 | 277 | if sys.version_info < (3, 3): |
|
278 | 278 | extras_require['test'].append('mock') |
|
279 | 279 | |
|
280 | 280 | extras_require['notebook'].extend(extras_require['nbformat']) |
|
281 | 281 | extras_require['nbconvert'].extend(extras_require['nbformat']) |
|
282 | 282 | |
|
283 | 283 | everything = set() |
|
284 | 284 | for deps in extras_require.values(): |
|
285 | 285 | everything.update(deps) |
|
286 | 286 | extras_require['all'] = everything |
|
287 | 287 | |
|
288 | 288 | install_requires = [] |
|
289 | 289 | |
|
290 | 290 | # add readline |
|
291 | 291 | if sys.platform == 'darwin': |
|
292 | if not setupext.check_for_readline(): | |
|
292 | if 'bdist_wheel' in sys.argv[1:] or not setupext.check_for_readline(): | |
|
293 | 293 | install_requires.append('gnureadline') |
|
294 | 294 | elif sys.platform.startswith('win'): |
|
295 | 295 | extras_require['terminal'].append('pyreadline>=2.0') |
|
296 | 296 | |
|
297 | 297 | |
|
298 | 298 | if 'setuptools' in sys.modules: |
|
299 | 299 | # setup.py develop should check for submodules |
|
300 | 300 | from setuptools.command.develop import develop |
|
301 | 301 | setup_args['cmdclass']['develop'] = require_submodules(develop) |
|
302 | 302 | setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel()) |
|
303 | 303 | |
|
304 | 304 | setuptools_extra_args['zip_safe'] = False |
|
305 | 305 | setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()} |
|
306 | 306 | setup_args['extras_require'] = extras_require |
|
307 | 307 | requires = setup_args['install_requires'] = install_requires |
|
308 | 308 | |
|
309 | 309 | # Script to be run by the windows binary installer after the default setup |
|
310 | 310 | # routine, to add shortcuts and similar windows-only things. Windows |
|
311 | 311 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils |
|
312 | 312 | # doesn't find them. |
|
313 | 313 | if 'bdist_wininst' in sys.argv: |
|
314 | 314 | if len(sys.argv) > 2 and \ |
|
315 | 315 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): |
|
316 | 316 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." |
|
317 | 317 | sys.exit(1) |
|
318 | 318 | setup_args['data_files'].append( |
|
319 | 319 | ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')]) |
|
320 | 320 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] |
|
321 | 321 | setup_args['options'] = {"bdist_wininst": |
|
322 | 322 | {"install_script": |
|
323 | 323 | "ipython_win_post_install.py"}} |
|
324 | 324 | |
|
325 | 325 | else: |
|
326 | 326 | # If we are installing without setuptools, call this function which will |
|
327 | 327 | # check for dependencies an inform the user what is needed. This is |
|
328 | 328 | # just to make life easy for users. |
|
329 | 329 | for install_cmd in ('install', 'symlink'): |
|
330 | 330 | if install_cmd in sys.argv: |
|
331 | 331 | check_for_dependencies() |
|
332 | 332 | break |
|
333 | 333 | # scripts has to be a non-empty list, or install_scripts isn't called |
|
334 | 334 | setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()] |
|
335 | 335 | |
|
336 | 336 | setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt |
|
337 | 337 | |
|
338 | 338 | #--------------------------------------------------------------------------- |
|
339 | 339 | # Do the actual setup now |
|
340 | 340 | #--------------------------------------------------------------------------- |
|
341 | 341 | |
|
342 | 342 | setup_args.update(setuptools_extra_args) |
|
343 | 343 | |
|
344 | 344 | def main(): |
|
345 | 345 | setup(**setup_args) |
|
346 | 346 | cleanup() |
|
347 | 347 | |
|
348 | 348 | if __name__ == '__main__': |
|
349 | 349 | main() |
General Comments 0
You need to be logged in to leave comments.
Login now