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