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