Show More
@@ -1,11 +1,286 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | """This calls the setup routine for Python 2 or 3 as required.""" | |
|
2 | # -*- coding: utf-8 -*- | |
|
3 | """Setup script for IPython. | |
|
4 | ||
|
5 | Under Posix environments it works like a typical setup.py script. | |
|
6 | Under Windows, the command sdist is not supported, since IPython | |
|
7 | requires utilities which are not available under Windows.""" | |
|
8 | ||
|
9 | #----------------------------------------------------------------------------- | |
|
10 | # Copyright (c) 2008-2011, IPython Development Team. | |
|
11 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> | |
|
12 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> | |
|
13 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> | |
|
14 | # | |
|
15 | # Distributed under the terms of the Modified BSD License. | |
|
16 | # | |
|
17 | # The full license is in the file COPYING.txt, distributed with this software. | |
|
18 | #----------------------------------------------------------------------------- | |
|
19 | ||
|
20 | #----------------------------------------------------------------------------- | |
|
21 | # Minimal Python version sanity check | |
|
22 | #----------------------------------------------------------------------------- | |
|
23 | from __future__ import print_function | |
|
3 | 24 | |
|
4 | 25 | import sys |
|
5 | 26 | |
|
6 | if sys.version_info[0] >= 3: | |
|
7 | from setup3 import main | |
|
27 | # This check is also made in IPython/__init__, don't forget to update both when | |
|
28 | # changing Python version requirements. | |
|
29 | #~ if sys.version[0:3] < '2.6': | |
|
30 | #~ error = """\ | |
|
31 | #~ ERROR: 'IPython requires Python Version 2.6 or above.' | |
|
32 | #~ Exiting.""" | |
|
33 | #~ print >> sys.stderr, error | |
|
34 | #~ sys.exit(1) | |
|
35 | ||
|
36 | PY3 = (sys.version_info[0] >= 3) | |
|
37 | ||
|
38 | # At least we're on the python version we need, move on. | |
|
39 | ||
|
40 | #------------------------------------------------------------------------------- | |
|
41 | # Imports | |
|
42 | #------------------------------------------------------------------------------- | |
|
43 | ||
|
44 | # Stdlib imports | |
|
45 | import os | |
|
46 | import shutil | |
|
47 | ||
|
48 | from glob import glob | |
|
49 | ||
|
50 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly | |
|
51 | # update it when the contents of directories change. | |
|
52 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') | |
|
53 | ||
|
54 | from distutils.core import setup | |
|
55 | ||
|
56 | # On Python 3, we need distribute (new setuptools) to do the 2to3 conversion | |
|
57 | if PY3: | |
|
58 | import setuptools | |
|
59 | ||
|
60 | # Our own imports | |
|
61 | from setupbase import target_update | |
|
62 | ||
|
63 | from setupbase import ( | |
|
64 | setup_args, | |
|
65 | find_packages, | |
|
66 | find_package_data, | |
|
67 | find_scripts, | |
|
68 | find_data_files, | |
|
69 | check_for_dependencies, | |
|
70 | record_commit_info, | |
|
71 | ) | |
|
72 | from setupext import setupext | |
|
73 | ||
|
74 | isfile = os.path.isfile | |
|
75 | pjoin = os.path.join | |
|
76 | ||
|
77 | #----------------------------------------------------------------------------- | |
|
78 | # Function definitions | |
|
79 | #----------------------------------------------------------------------------- | |
|
80 | ||
|
81 | def cleanup(): | |
|
82 | """Clean up the junk left around by the build process""" | |
|
83 | if "develop" not in sys.argv: | |
|
84 | try: | |
|
85 | shutil.rmtree('ipython.egg-info') | |
|
86 | except: | |
|
87 | try: | |
|
88 | os.unlink('ipython.egg-info') | |
|
89 | except: | |
|
90 | pass | |
|
91 | ||
|
92 | #------------------------------------------------------------------------------- | |
|
93 | # Handle OS specific things | |
|
94 | #------------------------------------------------------------------------------- | |
|
95 | ||
|
96 | if os.name == 'posix': | |
|
97 | os_name = 'posix' | |
|
98 | elif os.name in ['nt','dos']: | |
|
99 | os_name = 'windows' | |
|
8 | 100 | else: |
|
9 | from setup2 import main | |
|
101 | print('Unsupported operating system:',os.name) | |
|
102 | sys.exit(1) | |
|
103 | ||
|
104 | # 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 | |
|
106 | # actually works. | |
|
107 | if os_name == 'windows' and 'sdist' in sys.argv: | |
|
108 | print('The sdist command is not available under Windows. Exiting.') | |
|
109 | sys.exit(1) | |
|
110 | ||
|
111 | #------------------------------------------------------------------------------- | |
|
112 | # Things related to the IPython documentation | |
|
113 | #------------------------------------------------------------------------------- | |
|
114 | ||
|
115 | # update the manuals when building a source dist | |
|
116 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): | |
|
117 | import textwrap | |
|
118 | ||
|
119 | # List of things to be updated. Each entry is a triplet of args for | |
|
120 | # target_update() | |
|
121 | to_update = [ | |
|
122 | # FIXME - Disabled for now: we need to redo an automatic way | |
|
123 | # of generating the magic info inside the rst. | |
|
124 | #('docs/magic.tex', | |
|
125 | #['IPython/Magic.py'], | |
|
126 | #"cd doc && ./update_magic.sh" ), | |
|
127 | ||
|
128 | ('docs/man/ipcluster.1.gz', | |
|
129 | ['docs/man/ipcluster.1'], | |
|
130 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), | |
|
131 | ||
|
132 | ('docs/man/ipcontroller.1.gz', | |
|
133 | ['docs/man/ipcontroller.1'], | |
|
134 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), | |
|
135 | ||
|
136 | ('docs/man/ipengine.1.gz', | |
|
137 | ['docs/man/ipengine.1'], | |
|
138 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), | |
|
139 | ||
|
140 | ('docs/man/iplogger.1.gz', | |
|
141 | ['docs/man/iplogger.1'], | |
|
142 | 'cd docs/man && gzip -9c iplogger.1 > iplogger.1.gz'), | |
|
143 | ||
|
144 | ('docs/man/ipython.1.gz', | |
|
145 | ['docs/man/ipython.1'], | |
|
146 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), | |
|
147 | ||
|
148 | ('docs/man/irunner.1.gz', | |
|
149 | ['docs/man/irunner.1'], | |
|
150 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), | |
|
151 | ||
|
152 | ('docs/man/pycolor.1.gz', | |
|
153 | ['docs/man/pycolor.1'], | |
|
154 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), | |
|
155 | ] | |
|
156 | ||
|
157 | # Only build the docs if sphinx is present | |
|
158 | try: | |
|
159 | import sphinx | |
|
160 | except ImportError: | |
|
161 | pass | |
|
162 | else: | |
|
163 | # The Makefile calls the do_sphinx scripts to build html and pdf, so | |
|
164 | # just one target is enough to cover all manual generation | |
|
165 | ||
|
166 | # First, compute all the dependencies that can force us to rebuild the | |
|
167 | # docs. Start with the main release file that contains metadata | |
|
168 | docdeps = ['IPython/core/release.py'] | |
|
169 | # Inculde all the reST sources | |
|
170 | pjoin = os.path.join | |
|
171 | for dirpath,dirnames,filenames in os.walk('docs/source'): | |
|
172 | if dirpath in ['_static','_templates']: | |
|
173 | continue | |
|
174 | docdeps += [ pjoin(dirpath,f) for f in filenames | |
|
175 | if f.endswith('.txt') ] | |
|
176 | # and the examples | |
|
177 | for dirpath,dirnames,filenames in os.walk('docs/example'): | |
|
178 | docdeps += [ pjoin(dirpath,f) for f in filenames | |
|
179 | if not f.endswith('~') ] | |
|
180 | # then, make them all dependencies for the main html docs | |
|
181 | to_update.append( | |
|
182 | ('docs/dist/index.html', | |
|
183 | docdeps, | |
|
184 | "cd docs && make dist") | |
|
185 | ) | |
|
186 | ||
|
187 | [ target_update(*t) for t in to_update ] | |
|
188 | ||
|
189 | #--------------------------------------------------------------------------- | |
|
190 | # Find all the packages, package data, and data_files | |
|
191 | #--------------------------------------------------------------------------- | |
|
192 | ||
|
193 | packages = find_packages() | |
|
194 | package_data = find_package_data() | |
|
195 | data_files = find_data_files() | |
|
196 | ||
|
197 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython')} | |
|
198 | setup_args['packages'] = packages | |
|
199 | setup_args['package_data'] = package_data | |
|
200 | setup_args['data_files'] = data_files | |
|
201 | ||
|
202 | #--------------------------------------------------------------------------- | |
|
203 | # Handle scripts, dependencies, and setuptools specific things | |
|
204 | #--------------------------------------------------------------------------- | |
|
205 | ||
|
206 | # For some commands, use setuptools. Note that we do NOT list install here! | |
|
207 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' | |
|
208 | needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm', | |
|
209 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', | |
|
210 | 'egg_info', 'easy_install', 'upload', | |
|
211 | )) | |
|
212 | if sys.platform == 'win32': | |
|
213 | # Depend on setuptools for install on *Windows only* | |
|
214 | # If we get script-installation working without setuptools, | |
|
215 | # then we can back off, but until then use it. | |
|
216 | # See Issue #369 on GitHub for more | |
|
217 | needs_setuptools.add('install') | |
|
218 | ||
|
219 | if len(needs_setuptools.intersection(sys.argv)) > 0: | |
|
220 | import setuptools | |
|
221 | ||
|
222 | # This dict is used for passing extra arguments that are setuptools | |
|
223 | # specific to setup | |
|
224 | setuptools_extra_args = {} | |
|
225 | ||
|
226 | if 'setuptools' in sys.modules: | |
|
227 | setuptools_extra_args['zip_safe'] = False | |
|
228 | setuptools_extra_args['entry_points'] = find_scripts(True) | |
|
229 | setup_args['extras_require'] = dict( | |
|
230 | parallel = 'pyzmq>=2.1.4', | |
|
231 | zmq = 'pyzmq>=2.1.4', | |
|
232 | doc = 'Sphinx>=0.3', | |
|
233 | test = 'nose>=0.10.1', | |
|
234 | notebook = 'tornado>=2.0' | |
|
235 | ) | |
|
236 | requires = setup_args.setdefault('install_requires', []) | |
|
237 | setupext.display_status = False | |
|
238 | if not setupext.check_for_readline(): | |
|
239 | if sys.platform == 'darwin': | |
|
240 | requires.append('readline') | |
|
241 | elif sys.platform.startswith('win') and sys.maxsize < 2**32: | |
|
242 | # only require pyreadline on 32b Windows, due to 64b bug in pyreadline: | |
|
243 | # https://bugs.launchpad.net/pyreadline/+bug/787574 | |
|
244 | requires.append('pyreadline') | |
|
245 | else: | |
|
246 | pass | |
|
247 | # do we want to install readline here? | |
|
248 | ||
|
249 | # Script to be run by the windows binary installer after the default setup | |
|
250 | # routine, to add shortcuts and similar windows-only things. Windows | |
|
251 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils | |
|
252 | # doesn't find them. | |
|
253 | if 'bdist_wininst' in sys.argv: | |
|
254 | if len(sys.argv) > 2 and \ | |
|
255 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): | |
|
256 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." | |
|
257 | sys.exit(1) | |
|
258 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] | |
|
259 | setup_args['options'] = {"bdist_wininst": | |
|
260 | {"install_script": | |
|
261 | "ipython_win_post_install.py"}} | |
|
262 | ||
|
263 | if PY3: | |
|
264 | setuptools_extra_args['use_2to3'] = True | |
|
265 | from setuptools.command.build_py import build_py | |
|
266 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)} | |
|
267 | setuptools_extra_args['entry_points'] = find_scripts(True, suffix='3') | |
|
268 | else: | |
|
269 | # If we are running without setuptools, call this function which will | |
|
270 | # check for dependencies an inform the user what is needed. This is | |
|
271 | # just to make life easy for users. | |
|
272 | check_for_dependencies() | |
|
273 | setup_args['scripts'] = find_scripts(False) | |
|
274 | ||
|
275 | #--------------------------------------------------------------------------- | |
|
276 | # Do the actual setup now | |
|
277 | #--------------------------------------------------------------------------- | |
|
278 | ||
|
279 | setup_args.update(setuptools_extra_args) | |
|
280 | ||
|
281 | def main(): | |
|
282 | setup(**setup_args) | |
|
283 | cleanup() | |
|
10 | 284 | |
|
11 | main() | |
|
285 | if __name__ == '__main__': | |
|
286 | main() |
@@ -251,6 +251,44 b' def make_man_update_target(manpage):' | |||
|
251 | 251 | locals() ) |
|
252 | 252 | return (manpath_gz, [manpath], gz_cmd) |
|
253 | 253 | |
|
254 | # The two functions below are copied from IPython.utils.path, so we don't need | |
|
255 | # to import IPython during setup, which fails on Python 3. | |
|
256 | ||
|
257 | def target_outdated(target,deps): | |
|
258 | """Determine whether a target is out of date. | |
|
259 | ||
|
260 | target_outdated(target,deps) -> 1/0 | |
|
261 | ||
|
262 | deps: list of filenames which MUST exist. | |
|
263 | target: single filename which may or may not exist. | |
|
264 | ||
|
265 | If target doesn't exist or is older than any file listed in deps, return | |
|
266 | true, otherwise return false. | |
|
267 | """ | |
|
268 | try: | |
|
269 | target_time = os.path.getmtime(target) | |
|
270 | except os.error: | |
|
271 | return 1 | |
|
272 | for dep in deps: | |
|
273 | dep_time = os.path.getmtime(dep) | |
|
274 | if dep_time > target_time: | |
|
275 | #print "For target",target,"Dep failed:",dep # dbg | |
|
276 | #print "times (dep,tar):",dep_time,target_time # dbg | |
|
277 | return 1 | |
|
278 | return 0 | |
|
279 | ||
|
280 | ||
|
281 | def target_update(target,deps,cmd): | |
|
282 | """Update a target with a given command given a list of dependencies. | |
|
283 | ||
|
284 | target_update(target,deps,cmd) -> runs cmd if target is outdated. | |
|
285 | ||
|
286 | This is just a wrapper around target_outdated() which calls the given | |
|
287 | command if target is outdated.""" | |
|
288 | ||
|
289 | if target_outdated(target,deps): | |
|
290 | system(cmd) | |
|
291 | ||
|
254 | 292 | #--------------------------------------------------------------------------- |
|
255 | 293 | # Find scripts |
|
256 | 294 | #--------------------------------------------------------------------------- |
@@ -1,4 +1,5 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | from __future__ import print_function | |
|
2 | 3 | |
|
3 | 4 | __docformat__ = "restructuredtext en" |
|
4 | 5 | |
@@ -27,26 +28,26 b' def check_display(f):' | |||
|
27 | 28 | |
|
28 | 29 | @check_display |
|
29 | 30 | def print_line(char='='): |
|
30 |
print |
|
|
31 | print(char * 76) | |
|
31 | 32 | |
|
32 | 33 | @check_display |
|
33 | 34 | def print_status(package, status): |
|
34 | 35 | initial_indent = "%22s: " % package |
|
35 | 36 | indent = ' ' * 24 |
|
36 |
print |
|
|
37 | print(fill(str(status), width=76, | |
|
37 | 38 | initial_indent=initial_indent, |
|
38 | subsequent_indent=indent) | |
|
39 | subsequent_indent=indent)) | |
|
39 | 40 | |
|
40 | 41 | @check_display |
|
41 | 42 | def print_message(message): |
|
42 | 43 | indent = ' ' * 24 + "* " |
|
43 |
print |
|
|
44 | print(fill(str(message), width=76, | |
|
44 | 45 | initial_indent=indent, |
|
45 | subsequent_indent=indent) | |
|
46 | subsequent_indent=indent)) | |
|
46 | 47 | |
|
47 | 48 | @check_display |
|
48 | 49 | def print_raw(section): |
|
49 |
print |
|
|
50 | print(section) | |
|
50 | 51 | |
|
51 | 52 | #------------------------------------------------------------------------------- |
|
52 | 53 | # Tests for specific packages |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now