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