##// END OF EJS Templates
add 'all' extras...
MinRK -
Show More
@@ -1,348 +1,356 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.txt, 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 #~ if sys.version[0:3] < '2.6':
30 30 #~ error = """\
31 31 #~ ERROR: 'IPython requires Python Version 2.6 or above.'
32 32 #~ Exiting."""
33 33 #~ print >> sys.stderr, error
34 34 #~ sys.exit(1)
35 35
36 36 PY3 = (sys.version_info[0] >= 3)
37 37
38 38 # At least we're on the python version we need, move on.
39 39
40 40 #-------------------------------------------------------------------------------
41 41 # Imports
42 42 #-------------------------------------------------------------------------------
43 43
44 44 # Stdlib imports
45 45 import os
46 46 import shutil
47 47
48 48 from glob import glob
49 49
50 50 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
51 51 # update it when the contents of directories change.
52 52 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
53 53
54 54 from distutils.core import setup
55 55
56 56 # On Python 3, we need distribute (new setuptools) to do the 2to3 conversion
57 57 if PY3:
58 58 import setuptools
59 59
60 60 # Our own imports
61 61 from setupbase import target_update
62 62
63 63 from setupbase import (
64 64 setup_args,
65 65 find_packages,
66 66 find_package_data,
67 67 find_scripts,
68 68 find_data_files,
69 69 check_for_dependencies,
70 70 git_prebuild,
71 71 check_submodule_status,
72 72 update_submodules,
73 73 require_submodules,
74 74 UpdateSubmodules,
75 75 )
76 76 from setupext import setupext
77 77
78 78 isfile = os.path.isfile
79 79 pjoin = os.path.join
80 80
81 81 #-----------------------------------------------------------------------------
82 82 # Function definitions
83 83 #-----------------------------------------------------------------------------
84 84
85 85 def cleanup():
86 86 """Clean up the junk left around by the build process"""
87 87 if "develop" not in sys.argv and "egg_info" not in sys.argv:
88 88 try:
89 89 shutil.rmtree('ipython.egg-info')
90 90 except:
91 91 try:
92 92 os.unlink('ipython.egg-info')
93 93 except:
94 94 pass
95 95
96 96 #-------------------------------------------------------------------------------
97 97 # Handle OS specific things
98 98 #-------------------------------------------------------------------------------
99 99
100 100 if os.name in ('nt','dos'):
101 101 os_name = 'windows'
102 102 else:
103 103 os_name = os.name
104 104
105 105 # Under Windows, 'sdist' has not been supported. Now that the docs build with
106 106 # Sphinx it might work, but let's not turn it on until someone confirms that it
107 107 # actually works.
108 108 if os_name == 'windows' and 'sdist' in sys.argv:
109 109 print('The sdist command is not available under Windows. Exiting.')
110 110 sys.exit(1)
111 111
112 112 #-------------------------------------------------------------------------------
113 113 # Make sure we aren't trying to run without submodules
114 114 #-------------------------------------------------------------------------------
115 115 here = os.path.abspath(os.path.dirname(__file__))
116 116
117 117 def require_clean_submodules():
118 118 """Check on git submodules before distutils can do anything
119 119
120 120 Since distutils cannot be trusted to update the tree
121 121 after everything has been set in motion,
122 122 this is not a distutils command.
123 123 """
124 124 # PACKAGERS: Add a return here to skip checks for git submodules
125 125
126 126 # don't do anything if nothing is actually supposed to happen
127 127 for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'):
128 128 if do_nothing in sys.argv:
129 129 return
130 130
131 131 status = check_submodule_status(here)
132 132
133 133 if status == "missing":
134 134 print("checking out submodules for the first time")
135 135 update_submodules(here)
136 136 elif status == "unclean":
137 137 print('\n'.join([
138 138 "Cannot build / install IPython with unclean submodules",
139 139 "Please update submodules with",
140 140 " python setup.py submodule",
141 141 "or",
142 142 " git submodule update",
143 143 "or commit any submodule changes you have made."
144 144 ]))
145 145 sys.exit(1)
146 146
147 147 require_clean_submodules()
148 148
149 149 #-------------------------------------------------------------------------------
150 150 # Things related to the IPython documentation
151 151 #-------------------------------------------------------------------------------
152 152
153 153 # update the manuals when building a source dist
154 154 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
155 155 import textwrap
156 156
157 157 # List of things to be updated. Each entry is a triplet of args for
158 158 # target_update()
159 159 to_update = [
160 160 # FIXME - Disabled for now: we need to redo an automatic way
161 161 # of generating the magic info inside the rst.
162 162 #('docs/magic.tex',
163 163 #['IPython/Magic.py'],
164 164 #"cd doc && ./update_magic.sh" ),
165 165
166 166 ('docs/man/ipcluster.1.gz',
167 167 ['docs/man/ipcluster.1'],
168 168 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
169 169
170 170 ('docs/man/ipcontroller.1.gz',
171 171 ['docs/man/ipcontroller.1'],
172 172 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
173 173
174 174 ('docs/man/ipengine.1.gz',
175 175 ['docs/man/ipengine.1'],
176 176 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
177 177
178 178 ('docs/man/iplogger.1.gz',
179 179 ['docs/man/iplogger.1'],
180 180 'cd docs/man && gzip -9c iplogger.1 > iplogger.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 ('docs/man/irunner.1.gz',
187 187 ['docs/man/irunner.1'],
188 188 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'),
189 189
190 190 ('docs/man/pycolor.1.gz',
191 191 ['docs/man/pycolor.1'],
192 192 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'),
193 193 ]
194 194
195 195
196 196 [ target_update(*t) for t in to_update ]
197 197
198 198 #---------------------------------------------------------------------------
199 199 # Find all the packages, package data, and data_files
200 200 #---------------------------------------------------------------------------
201 201
202 202 packages = find_packages()
203 203 package_data = find_package_data()
204 204 data_files = find_data_files()
205 205
206 206 setup_args['packages'] = packages
207 207 setup_args['package_data'] = package_data
208 208 setup_args['data_files'] = data_files
209 209
210 210 #---------------------------------------------------------------------------
211 211 # custom distutils commands
212 212 #---------------------------------------------------------------------------
213 213 # imports here, so they are after setuptools import if there was one
214 214 from distutils.command.sdist import sdist
215 215 from distutils.command.upload import upload
216 216
217 217 class UploadWindowsInstallers(upload):
218 218
219 219 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
220 220 user_options = upload.user_options + [
221 221 ('files=', 'f', 'exe file (or glob) to upload')
222 222 ]
223 223 def initialize_options(self):
224 224 upload.initialize_options(self)
225 225 meta = self.distribution.metadata
226 226 base = '{name}-{version}'.format(
227 227 name=meta.get_name(),
228 228 version=meta.get_version()
229 229 )
230 230 self.files = os.path.join('dist', '%s.*.exe' % base)
231 231
232 232 def run(self):
233 233 for dist_file in glob(self.files):
234 234 self.upload_file('bdist_wininst', 'any', dist_file)
235 235
236 236 setup_args['cmdclass'] = {
237 237 'build_py': git_prebuild('IPython'),
238 238 'sdist' : git_prebuild('IPython', sdist),
239 239 'upload_wininst' : UploadWindowsInstallers,
240 240 'submodule' : UpdateSubmodules,
241 241 }
242 242
243 243 #---------------------------------------------------------------------------
244 244 # Handle scripts, dependencies, and setuptools specific things
245 245 #---------------------------------------------------------------------------
246 246
247 247 # For some commands, use setuptools. Note that we do NOT list install here!
248 248 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
249 249 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
250 250 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info',
251 251 'egg_info', 'easy_install', 'upload',
252 252 ))
253 253 if sys.platform == 'win32':
254 254 # Depend on setuptools for install on *Windows only*
255 255 # If we get script-installation working without setuptools,
256 256 # then we can back off, but until then use it.
257 257 # See Issue #369 on GitHub for more
258 258 needs_setuptools.add('install')
259 259
260 260 if len(needs_setuptools.intersection(sys.argv)) > 0:
261 261 import setuptools
262 262
263 263 # This dict is used for passing extra arguments that are setuptools
264 264 # specific to setup
265 265 setuptools_extra_args = {}
266 266
267 267 if 'setuptools' in sys.modules:
268 268 # setup.py develop should check for submodules
269 269 from setuptools.command.develop import develop
270 270 setup_args['cmdclass']['develop'] = require_submodules(develop)
271 271
272 272 setuptools_extra_args['zip_safe'] = False
273 273 setuptools_extra_args['entry_points'] = find_scripts(True)
274 274 setup_args['extras_require'] = dict(
275 275 parallel = 'pyzmq>=2.1.11',
276 276 qtconsole = ['pyzmq>=2.1.11', 'pygments'],
277 277 zmq = 'pyzmq>=2.1.11',
278 278 doc = 'Sphinx>=0.3',
279 279 test = 'nose>=0.10.1',
280 280 notebook = ['tornado>=2.0', 'pyzmq>=2.1.11', 'jinja2'],
281 281 nbconvert = ['pygments', 'jinja2', 'Sphinx>=0.3']
282 282 )
283 everything = set()
284 for deps in setup_args['extras_require'].values():
285 if not isinstance(deps, list):
286 deps = [deps]
287 for dep in deps:
288 everything.add(dep)
289 setup_args['extras_require']['all'] = everything
290
283 291 requires = setup_args.setdefault('install_requires', [])
284 292 setupext.display_status = False
285 293 if not setupext.check_for_readline():
286 294 if sys.platform == 'darwin':
287 295 requires.append('readline')
288 296 elif sys.platform.startswith('win'):
289 297 # Pyreadline 64 bit windows issue solved in versions >=1.7.1
290 298 # Also solves issues with some older versions of pyreadline that
291 299 # satisfy the unconstrained depdendency.
292 300 requires.append('pyreadline>=1.7.1')
293 301 else:
294 302 pass
295 303 # do we want to install readline here?
296 304
297 305 # Script to be run by the windows binary installer after the default setup
298 306 # routine, to add shortcuts and similar windows-only things. Windows
299 307 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
300 308 # doesn't find them.
301 309 if 'bdist_wininst' in sys.argv:
302 310 if len(sys.argv) > 2 and \
303 311 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
304 312 print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
305 313 sys.exit(1)
306 314 setup_args['data_files'].append(
307 315 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
308 316 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
309 317 setup_args['options'] = {"bdist_wininst":
310 318 {"install_script":
311 319 "ipython_win_post_install.py"}}
312 320
313 321 if PY3:
314 322 setuptools_extra_args['use_2to3'] = True
315 323 # we try to make a 2.6, 2.7, and 3.1 to 3.3 python compatible code
316 324 # so we explicitly disable some 2to3 fixes to be sure we aren't forgetting
317 325 # anything.
318 326 setuptools_extra_args['use_2to3_exclude_fixers'] = [
319 327 'lib2to3.fixes.fix_apply',
320 328 'lib2to3.fixes.fix_except',
321 329 'lib2to3.fixes.fix_has_key',
322 330 'lib2to3.fixes.fix_next',
323 331 'lib2to3.fixes.fix_repr',
324 332 'lib2to3.fixes.fix_tuple_params',
325 333 ]
326 334 from setuptools.command.build_py import build_py
327 335 setup_args['cmdclass'] = {'build_py': git_prebuild('IPython', build_cmd=build_py)}
328 336 setuptools_extra_args['entry_points'] = find_scripts(True, suffix='3')
329 337 setuptools._dont_write_bytecode = True
330 338 else:
331 339 # If we are running without setuptools, call this function which will
332 340 # check for dependencies an inform the user what is needed. This is
333 341 # just to make life easy for users.
334 342 check_for_dependencies()
335 343 setup_args['scripts'] = find_scripts(False)
336 344
337 345 #---------------------------------------------------------------------------
338 346 # Do the actual setup now
339 347 #---------------------------------------------------------------------------
340 348
341 349 setup_args.update(setuptools_extra_args)
342 350
343 351 def main():
344 352 setup(**setup_args)
345 353 cleanup()
346 354
347 355 if __name__ == '__main__':
348 356 main()
General Comments 0
You need to be logged in to leave comments. Login now