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