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