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