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