Show More
@@ -1,250 +1,251 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 The IPython Development Team |
|
10 | # Copyright (C) 2008 The IPython Development Team | |
11 | # |
|
11 | # | |
12 | # Distributed under the terms of the BSD License. The full license is in |
|
12 | # Distributed under the terms of the BSD License. The full license is in | |
13 | # the file COPYING, distributed as part of this software. |
|
13 | # the file COPYING, distributed as part of this software. | |
14 | #------------------------------------------------------------------------------- |
|
14 | #------------------------------------------------------------------------------- | |
15 |
|
15 | |||
16 | #----------------------------------------------------------------------------- |
|
16 | #----------------------------------------------------------------------------- | |
17 | # Minimal Python version sanity check |
|
17 | # Minimal Python version sanity check | |
18 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
19 |
|
19 | |||
20 | import sys |
|
20 | import sys | |
21 |
|
21 | |||
22 | # This check is also made in IPython/__init__, don't forget to update both when |
|
22 | # This check is also made in IPython/__init__, don't forget to update both when | |
23 | # changing Python version requirements. |
|
23 | # changing Python version requirements. | |
24 | if sys.version[0:3] < '2.5': |
|
24 | if sys.version[0:3] < '2.5': | |
25 | error = """\ |
|
25 | error = """\ | |
26 | ERROR: 'IPython requires Python Version 2.5 or above.' |
|
26 | ERROR: 'IPython requires Python Version 2.5 or above.' | |
27 | Exiting.""" |
|
27 | Exiting.""" | |
28 | print >> sys.stderr, error |
|
28 | print >> sys.stderr, error | |
29 | sys.exit(1) |
|
29 | sys.exit(1) | |
30 |
|
30 | |||
31 | # At least we're on Python 2.5 or newer, move on. |
|
31 | # At least we're on Python 2.5 or newer, move on. | |
32 |
|
32 | |||
33 | #------------------------------------------------------------------------------- |
|
33 | #------------------------------------------------------------------------------- | |
34 | # Imports |
|
34 | # Imports | |
35 | #------------------------------------------------------------------------------- |
|
35 | #------------------------------------------------------------------------------- | |
36 |
|
36 | |||
37 | # Stdlib imports |
|
37 | # Stdlib imports | |
38 | import os |
|
38 | import os | |
39 | import shutil |
|
39 | import shutil | |
40 |
|
40 | |||
41 | from glob import glob |
|
41 | from glob import glob | |
42 |
|
42 | |||
43 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
43 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly | |
44 | # update it when the contents of directories change. |
|
44 | # update it when the contents of directories change. | |
45 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
45 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') | |
46 |
|
46 | |||
47 | from distutils.core import setup |
|
47 | from distutils.core import setup | |
48 |
|
48 | |||
49 | # Our own imports |
|
49 | # Our own imports | |
50 | from IPython.utils.path import target_update |
|
50 | from IPython.utils.path import target_update | |
51 |
|
51 | |||
52 | from setupbase import ( |
|
52 | from setupbase import ( | |
53 | setup_args, |
|
53 | setup_args, | |
54 | find_packages, |
|
54 | find_packages, | |
55 | find_package_data, |
|
55 | find_package_data, | |
56 | find_scripts, |
|
56 | find_scripts, | |
57 | find_data_files, |
|
57 | find_data_files, | |
58 | check_for_dependencies |
|
58 | check_for_dependencies | |
59 | ) |
|
59 | ) | |
60 |
|
60 | |||
61 | isfile = os.path.isfile |
|
61 | isfile = os.path.isfile | |
62 | pjoin = os.path.join |
|
62 | pjoin = os.path.join | |
63 |
|
63 | |||
64 | #----------------------------------------------------------------------------- |
|
64 | #----------------------------------------------------------------------------- | |
65 | # Function definitions |
|
65 | # Function definitions | |
66 | #----------------------------------------------------------------------------- |
|
66 | #----------------------------------------------------------------------------- | |
67 |
|
67 | |||
68 | def cleanup(): |
|
68 | def cleanup(): | |
69 | """Clean up the junk left around by the build process""" |
|
69 | """Clean up the junk left around by the build process""" | |
70 | if "develop" not in sys.argv: |
|
70 | if "develop" not in sys.argv: | |
71 | try: |
|
71 | try: | |
72 | shutil.rmtree('ipython.egg-info') |
|
72 | shutil.rmtree('ipython.egg-info') | |
73 | except: |
|
73 | except: | |
74 | try: |
|
74 | try: | |
75 | os.unlink('ipython.egg-info') |
|
75 | os.unlink('ipython.egg-info') | |
76 | except: |
|
76 | except: | |
77 | pass |
|
77 | pass | |
78 |
|
78 | |||
79 | #------------------------------------------------------------------------------- |
|
79 | #------------------------------------------------------------------------------- | |
80 | # Handle OS specific things |
|
80 | # Handle OS specific things | |
81 | #------------------------------------------------------------------------------- |
|
81 | #------------------------------------------------------------------------------- | |
82 |
|
82 | |||
83 | if os.name == 'posix': |
|
83 | if os.name == 'posix': | |
84 | os_name = 'posix' |
|
84 | os_name = 'posix' | |
85 | elif os.name in ['nt','dos']: |
|
85 | elif os.name in ['nt','dos']: | |
86 | os_name = 'windows' |
|
86 | os_name = 'windows' | |
87 | else: |
|
87 | else: | |
88 | print 'Unsupported operating system:',os.name |
|
88 | print 'Unsupported operating system:',os.name | |
89 | sys.exit(1) |
|
89 | sys.exit(1) | |
90 |
|
90 | |||
91 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
91 | # Under Windows, 'sdist' has not been supported. Now that the docs build with | |
92 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
92 | # Sphinx it might work, but let's not turn it on until someone confirms that it | |
93 | # actually works. |
|
93 | # actually works. | |
94 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
94 | if os_name == 'windows' and 'sdist' in sys.argv: | |
95 | print 'The sdist command is not available under Windows. Exiting.' |
|
95 | print 'The sdist command is not available under Windows. Exiting.' | |
96 | sys.exit(1) |
|
96 | sys.exit(1) | |
97 |
|
97 | |||
98 | #------------------------------------------------------------------------------- |
|
98 | #------------------------------------------------------------------------------- | |
99 | # Things related to the IPython documentation |
|
99 | # Things related to the IPython documentation | |
100 | #------------------------------------------------------------------------------- |
|
100 | #------------------------------------------------------------------------------- | |
101 |
|
101 | |||
102 | # update the manuals when building a source dist |
|
102 | # update the manuals when building a source dist | |
103 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
103 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): | |
104 | import textwrap |
|
104 | import textwrap | |
105 |
|
105 | |||
106 | # List of things to be updated. Each entry is a triplet of args for |
|
106 | # List of things to be updated. Each entry is a triplet of args for | |
107 | # target_update() |
|
107 | # target_update() | |
108 | to_update = [ |
|
108 | to_update = [ | |
109 | # FIXME - Disabled for now: we need to redo an automatic way |
|
109 | # FIXME - Disabled for now: we need to redo an automatic way | |
110 | # of generating the magic info inside the rst. |
|
110 | # of generating the magic info inside the rst. | |
111 | #('docs/magic.tex', |
|
111 | #('docs/magic.tex', | |
112 | #['IPython/Magic.py'], |
|
112 | #['IPython/Magic.py'], | |
113 | #"cd doc && ./update_magic.sh" ), |
|
113 | #"cd doc && ./update_magic.sh" ), | |
114 |
|
114 | |||
115 | ('docs/man/ipcluster.1.gz', |
|
115 | ('docs/man/ipcluster.1.gz', | |
116 | ['docs/man/ipcluster.1'], |
|
116 | ['docs/man/ipcluster.1'], | |
117 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), |
|
117 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), | |
118 |
|
118 | |||
119 | ('docs/man/ipcontroller.1.gz', |
|
119 | ('docs/man/ipcontroller.1.gz', | |
120 | ['docs/man/ipcontroller.1'], |
|
120 | ['docs/man/ipcontroller.1'], | |
121 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), |
|
121 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), | |
122 |
|
122 | |||
123 | ('docs/man/ipengine.1.gz', |
|
123 | ('docs/man/ipengine.1.gz', | |
124 | ['docs/man/ipengine.1'], |
|
124 | ['docs/man/ipengine.1'], | |
125 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), |
|
125 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), | |
126 |
|
126 | |||
127 | ('docs/man/ipython.1.gz', |
|
127 | ('docs/man/ipython.1.gz', | |
128 | ['docs/man/ipython.1'], |
|
128 | ['docs/man/ipython.1'], | |
129 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
129 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), | |
130 |
|
130 | |||
131 | ('docs/man/ipython-wx.1.gz', |
|
131 | ('docs/man/ipython-wx.1.gz', | |
132 | ['docs/man/ipython-wx.1'], |
|
132 | ['docs/man/ipython-wx.1'], | |
133 | 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'), |
|
133 | 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'), | |
134 |
|
134 | |||
135 | ('docs/man/ipythonx.1.gz', |
|
135 | ('docs/man/ipythonx.1.gz', | |
136 | ['docs/man/ipythonx.1'], |
|
136 | ['docs/man/ipythonx.1'], | |
137 | 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'), |
|
137 | 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'), | |
138 |
|
138 | |||
139 | ('docs/man/irunner.1.gz', |
|
139 | ('docs/man/irunner.1.gz', | |
140 | ['docs/man/irunner.1'], |
|
140 | ['docs/man/irunner.1'], | |
141 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), |
|
141 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), | |
142 |
|
142 | |||
143 | ('docs/man/pycolor.1.gz', |
|
143 | ('docs/man/pycolor.1.gz', | |
144 | ['docs/man/pycolor.1'], |
|
144 | ['docs/man/pycolor.1'], | |
145 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), |
|
145 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), | |
146 | ] |
|
146 | ] | |
147 |
|
147 | |||
148 | # Only build the docs if sphinx is present |
|
148 | # Only build the docs if sphinx is present | |
149 | try: |
|
149 | try: | |
150 | import sphinx |
|
150 | import sphinx | |
151 | except ImportError: |
|
151 | except ImportError: | |
152 | pass |
|
152 | pass | |
153 | else: |
|
153 | else: | |
154 | # The Makefile calls the do_sphinx scripts to build html and pdf, so |
|
154 | # The Makefile calls the do_sphinx scripts to build html and pdf, so | |
155 | # just one target is enough to cover all manual generation |
|
155 | # just one target is enough to cover all manual generation | |
156 |
|
156 | |||
157 | # First, compute all the dependencies that can force us to rebuild the |
|
157 | # First, compute all the dependencies that can force us to rebuild the | |
158 | # docs. Start with the main release file that contains metadata |
|
158 | # docs. Start with the main release file that contains metadata | |
159 | docdeps = ['IPython/core/release.py'] |
|
159 | docdeps = ['IPython/core/release.py'] | |
160 | # Inculde all the reST sources |
|
160 | # Inculde all the reST sources | |
161 | pjoin = os.path.join |
|
161 | pjoin = os.path.join | |
162 | for dirpath,dirnames,filenames in os.walk('docs/source'): |
|
162 | for dirpath,dirnames,filenames in os.walk('docs/source'): | |
163 | if dirpath in ['_static','_templates']: |
|
163 | if dirpath in ['_static','_templates']: | |
164 | continue |
|
164 | continue | |
165 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
165 | docdeps += [ pjoin(dirpath,f) for f in filenames | |
166 | if f.endswith('.txt') ] |
|
166 | if f.endswith('.txt') ] | |
167 | # and the examples |
|
167 | # and the examples | |
168 | for dirpath,dirnames,filenames in os.walk('docs/example'): |
|
168 | for dirpath,dirnames,filenames in os.walk('docs/example'): | |
169 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
169 | docdeps += [ pjoin(dirpath,f) for f in filenames | |
170 | if not f.endswith('~') ] |
|
170 | if not f.endswith('~') ] | |
171 | # then, make them all dependencies for the main PDF (the html will get |
|
171 | # then, make them all dependencies for the main PDF (the html will get | |
172 | # auto-generated as well). |
|
172 | # auto-generated as well). | |
173 | to_update.append( |
|
173 | to_update.append( | |
174 | ('docs/dist/ipython.pdf', |
|
174 | ('docs/dist/ipython.pdf', | |
175 | docdeps, |
|
175 | docdeps, | |
176 | "cd docs && make dist") |
|
176 | "cd docs && make dist") | |
177 | ) |
|
177 | ) | |
178 |
|
178 | |||
179 | [ target_update(*t) for t in to_update ] |
|
179 | [ target_update(*t) for t in to_update ] | |
180 |
|
180 | |||
181 | #--------------------------------------------------------------------------- |
|
181 | #--------------------------------------------------------------------------- | |
182 | # Find all the packages, package data, scripts and data_files |
|
182 | # Find all the packages, package data, scripts and data_files | |
183 | #--------------------------------------------------------------------------- |
|
183 | #--------------------------------------------------------------------------- | |
184 |
|
184 | |||
185 | packages = find_packages() |
|
185 | packages = find_packages() | |
186 | package_data = find_package_data() |
|
186 | package_data = find_package_data() | |
187 | scripts = find_scripts() |
|
187 | scripts = find_scripts() | |
188 | data_files = find_data_files() |
|
188 | data_files = find_data_files() | |
189 |
|
189 | |||
190 | #--------------------------------------------------------------------------- |
|
190 | #--------------------------------------------------------------------------- | |
191 | # Handle dependencies and setuptools specific things |
|
191 | # Handle dependencies and setuptools specific things | |
192 | #--------------------------------------------------------------------------- |
|
192 | #--------------------------------------------------------------------------- | |
193 |
|
193 | |||
194 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
194 | # For some commands, use setuptools. Note that we do NOT list install here! | |
195 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
195 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' | |
196 | if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm', |
|
196 | if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm', | |
197 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', |
|
197 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', | |
198 | 'build_sphinx', 'egg_info', 'easy_install', 'upload', |
|
198 | 'build_sphinx', 'egg_info', 'easy_install', 'upload', | |
199 | )).intersection(sys.argv)) > 0: |
|
199 | )).intersection(sys.argv)) > 0: | |
200 | import setuptools |
|
200 | import setuptools | |
201 |
|
201 | |||
202 | # This dict is used for passing extra arguments that are setuptools |
|
202 | # This dict is used for passing extra arguments that are setuptools | |
203 | # specific to setup |
|
203 | # specific to setup | |
204 | setuptools_extra_args = {} |
|
204 | setuptools_extra_args = {} | |
205 |
|
205 | |||
206 | if 'setuptools' in sys.modules: |
|
206 | if 'setuptools' in sys.modules: | |
207 | setuptools_extra_args['zip_safe'] = False |
|
207 | setuptools_extra_args['zip_safe'] = False | |
208 | setuptools_extra_args['entry_points'] = { |
|
208 | setuptools_extra_args['entry_points'] = { | |
209 | 'console_scripts': [ |
|
209 | 'console_scripts': [ | |
210 | 'ipython = IPython.frontend.terminal.ipapp:launch_new_instance', |
|
210 | 'ipython = IPython.frontend.terminal.ipapp:launch_new_instance', | |
|
211 | 'ipythonqt = IPython.frontend.qt.console.ipythonqt:main', | |||
211 | 'pycolor = IPython.utils.PyColorize:main', |
|
212 | 'pycolor = IPython.utils.PyColorize:main', | |
212 | 'ipcontroller = IPython.kernel.ipcontrollerapp:launch_new_instance', |
|
213 | 'ipcontroller = IPython.kernel.ipcontrollerapp:launch_new_instance', | |
213 | 'ipengine = IPython.kernel.ipengineapp:launch_new_instance', |
|
214 | 'ipengine = IPython.kernel.ipengineapp:launch_new_instance', | |
214 | 'ipcluster = IPython.kernel.ipclusterapp:launch_new_instance', |
|
215 | 'ipcluster = IPython.kernel.ipclusterapp:launch_new_instance', | |
215 | 'iptest = IPython.testing.iptest:main', |
|
216 | 'iptest = IPython.testing.iptest:main', | |
216 | 'irunner = IPython.lib.irunner:main' |
|
217 | 'irunner = IPython.lib.irunner:main' | |
217 | ] |
|
218 | ] | |
218 | } |
|
219 | } | |
219 | setup_args['extras_require'] = dict( |
|
220 | setup_args['extras_require'] = dict( | |
220 | kernel = [ |
|
221 | kernel = [ | |
221 | 'zope.interface>=3.4.1', |
|
222 | 'zope.interface>=3.4.1', | |
222 | 'Twisted>=8.0.1', |
|
223 | 'Twisted>=8.0.1', | |
223 | 'foolscap>=0.2.6' |
|
224 | 'foolscap>=0.2.6' | |
224 | ], |
|
225 | ], | |
225 | doc='Sphinx>=0.3', |
|
226 | doc='Sphinx>=0.3', | |
226 | test='nose>=0.10.1', |
|
227 | test='nose>=0.10.1', | |
227 | security='pyOpenSSL>=0.6' |
|
228 | security='pyOpenSSL>=0.6' | |
228 | ) |
|
229 | ) | |
229 | # Allow setuptools to handle the scripts |
|
230 | # Allow setuptools to handle the scripts | |
230 | scripts = [] |
|
231 | scripts = [] | |
231 | else: |
|
232 | else: | |
232 | # If we are running without setuptools, call this function which will |
|
233 | # If we are running without setuptools, call this function which will | |
233 | # check for dependencies an inform the user what is needed. This is |
|
234 | # check for dependencies an inform the user what is needed. This is | |
234 | # just to make life easy for users. |
|
235 | # just to make life easy for users. | |
235 | check_for_dependencies() |
|
236 | check_for_dependencies() | |
236 |
|
237 | |||
237 | #--------------------------------------------------------------------------- |
|
238 | #--------------------------------------------------------------------------- | |
238 | # Do the actual setup now |
|
239 | # Do the actual setup now | |
239 | #--------------------------------------------------------------------------- |
|
240 | #--------------------------------------------------------------------------- | |
240 |
|
241 | |||
241 | setup_args['packages'] = packages |
|
242 | setup_args['packages'] = packages | |
242 | setup_args['package_data'] = package_data |
|
243 | setup_args['package_data'] = package_data | |
243 | setup_args['scripts'] = scripts |
|
244 | setup_args['scripts'] = scripts | |
244 | setup_args['data_files'] = data_files |
|
245 | setup_args['data_files'] = data_files | |
245 | setup_args.update(setuptools_extra_args) |
|
246 | setup_args.update(setuptools_extra_args) | |
246 |
|
247 | |||
247 |
|
248 | |||
248 | if __name__ == '__main__': |
|
249 | if __name__ == '__main__': | |
249 | setup(**setup_args) |
|
250 | setup(**setup_args) | |
250 | cleanup() |
|
251 | cleanup() |
General Comments 0
You need to be logged in to leave comments.
Login now