##// END OF EJS Templates
Fixed small bug in setup.py....
Brian Granger -
Show More
@@ -1,321 +1,320 b''
1 # encoding: utf-8
1 # encoding: utf-8
2
2
3 """
3 """
4 This module defines the things that are used in setup.py for building IPython
4 This module defines the things that are used in setup.py for building IPython
5
5
6 This includes:
6 This includes:
7
7
8 * The basic arguments to setup
8 * The basic arguments to setup
9 * Functions for finding things like packages, package data, etc.
9 * Functions for finding things like packages, package data, etc.
10 * A function for checking dependencies.
10 * A function for checking dependencies.
11 """
11 """
12
12
13 __docformat__ = "restructuredtext en"
13 __docformat__ = "restructuredtext en"
14
14
15 #-------------------------------------------------------------------------------
15 #-------------------------------------------------------------------------------
16 # Copyright (C) 2008 The IPython Development Team
16 # Copyright (C) 2008 The IPython Development Team
17 #
17 #
18 # Distributed under the terms of the BSD License. The full license is in
18 # Distributed under the terms of the BSD License. The full license is in
19 # the file COPYING, distributed as part of this software.
19 # the file COPYING, distributed as part of this software.
20 #-------------------------------------------------------------------------------
20 #-------------------------------------------------------------------------------
21
21
22 #-------------------------------------------------------------------------------
22 #-------------------------------------------------------------------------------
23 # Imports
23 # Imports
24 #-------------------------------------------------------------------------------
24 #-------------------------------------------------------------------------------
25
25
26 import os, sys
26 import os, sys
27
27
28 from glob import glob
28 from glob import glob
29
29
30 from setupext import install_data_ext
30 from setupext import install_data_ext
31
31
32 #-------------------------------------------------------------------------------
32 #-------------------------------------------------------------------------------
33 # Useful globals and utility functions
33 # Useful globals and utility functions
34 #-------------------------------------------------------------------------------
34 #-------------------------------------------------------------------------------
35
35
36 # A few handy globals
36 # A few handy globals
37 isfile = os.path.isfile
37 isfile = os.path.isfile
38 pjoin = os.path.join
38 pjoin = os.path.join
39
39
40 def oscmd(s):
40 def oscmd(s):
41 print ">", s
41 print ">", s
42 os.system(s)
42 os.system(s)
43
43
44 # A little utility we'll need below, since glob() does NOT allow you to do
44 # A little utility we'll need below, since glob() does NOT allow you to do
45 # exclusion on multiple endings!
45 # exclusion on multiple endings!
46 def file_doesnt_endwith(test,endings):
46 def file_doesnt_endwith(test,endings):
47 """Return true if test is a file and its name does NOT end with any
47 """Return true if test is a file and its name does NOT end with any
48 of the strings listed in endings."""
48 of the strings listed in endings."""
49 if not isfile(test):
49 if not isfile(test):
50 return False
50 return False
51 for e in endings:
51 for e in endings:
52 if test.endswith(e):
52 if test.endswith(e):
53 return False
53 return False
54 return True
54 return True
55
55
56 #---------------------------------------------------------------------------
56 #---------------------------------------------------------------------------
57 # Basic project information
57 # Basic project information
58 #---------------------------------------------------------------------------
58 #---------------------------------------------------------------------------
59
59
60 # release.py contains version, authors, license, url, keywords, etc.
60 # release.py contains version, authors, license, url, keywords, etc.
61 execfile(pjoin('IPython','core','release.py'))
61 execfile(pjoin('IPython','core','release.py'))
62
62
63 # Create a dict with the basic information
63 # Create a dict with the basic information
64 # This dict is eventually passed to setup after additional keys are added.
64 # This dict is eventually passed to setup after additional keys are added.
65 setup_args = dict(
65 setup_args = dict(
66 name = name,
66 name = name,
67 version = version,
67 version = version,
68 description = description,
68 description = description,
69 long_description = long_description,
69 long_description = long_description,
70 author = author,
70 author = author,
71 author_email = author_email,
71 author_email = author_email,
72 url = url,
72 url = url,
73 download_url = download_url,
73 download_url = download_url,
74 license = license,
74 license = license,
75 platforms = platforms,
75 platforms = platforms,
76 keywords = keywords,
76 keywords = keywords,
77 cmdclass = {'install_data': install_data_ext},
77 cmdclass = {'install_data': install_data_ext},
78 )
78 )
79
79
80
80
81 #---------------------------------------------------------------------------
81 #---------------------------------------------------------------------------
82 # Find packages
82 # Find packages
83 #---------------------------------------------------------------------------
83 #---------------------------------------------------------------------------
84
84
85 def add_package(packages,pname,config=False,tests=False,scripts=False,
85 def add_package(packages,pname,config=False,tests=False,scripts=False,
86 others=None):
86 others=None):
87 """
87 """
88 Add a package to the list of packages, including certain subpackages.
88 Add a package to the list of packages, including certain subpackages.
89 """
89 """
90 packages.append('.'.join(['IPython',pname]))
90 packages.append('.'.join(['IPython',pname]))
91 if config:
91 if config:
92 packages.append('.'.join(['IPython',pname,'config']))
92 packages.append('.'.join(['IPython',pname,'config']))
93 if tests:
93 if tests:
94 packages.append('.'.join(['IPython',pname,'tests']))
94 packages.append('.'.join(['IPython',pname,'tests']))
95 if scripts:
95 if scripts:
96 packages.append('.'.join(['IPython',pname,'scripts']))
96 packages.append('.'.join(['IPython',pname,'scripts']))
97 if others is not None:
97 if others is not None:
98 for o in others:
98 for o in others:
99 packages.append('.'.join(['IPython',pname,o]))
99 packages.append('.'.join(['IPython',pname,o]))
100
100
101 def find_packages():
101 def find_packages():
102 """
102 """
103 Find all of IPython's packages.
103 Find all of IPython's packages.
104 """
104 """
105 packages = ['IPython']
105 packages = ['IPython']
106 add_package(packages, 'config', tests=True)
106 add_package(packages, 'config', tests=True)
107 add_package(packages, 'config.userconfig')
108 add_package(packages, 'core', tests=True)
107 add_package(packages, 'core', tests=True)
109 add_package(packages, 'deathrow', tests=True)
108 add_package(packages, 'deathrow', tests=True)
110 add_package(packages , 'extensions')
109 add_package(packages , 'extensions')
111 add_package(packages, 'external')
110 add_package(packages, 'external')
112 add_package(packages, 'frontend', tests=True)
111 add_package(packages, 'frontend', tests=True)
113 # Don't include the cocoa frontend for now as it is not stable
112 # Don't include the cocoa frontend for now as it is not stable
114 if sys.platform == 'darwin' and False:
113 if sys.platform == 'darwin' and False:
115 add_package(packages, 'frontend.cocoa', tests=True, others=['plugin'])
114 add_package(packages, 'frontend.cocoa', tests=True, others=['plugin'])
116 add_package(packages, 'frontend.cocoa.examples')
115 add_package(packages, 'frontend.cocoa.examples')
117 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox')
116 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox')
118 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox.English.lproj')
117 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox.English.lproj')
119 add_package(packages, 'frontend.process')
118 add_package(packages, 'frontend.process')
120 add_package(packages, 'frontend.wx')
119 add_package(packages, 'frontend.wx')
121 add_package(packages, 'gui')
120 add_package(packages, 'gui')
122 add_package(packages, 'gui.wx')
121 add_package(packages, 'gui.wx')
123 add_package(packages, 'kernel', config=True, tests=True, scripts=True)
122 add_package(packages, 'kernel', config=True, tests=True, scripts=True)
124 add_package(packages, 'kernel.core', config=True, tests=True)
123 add_package(packages, 'kernel.core', config=True, tests=True)
125 add_package(packages, 'lib', tests=True)
124 add_package(packages, 'lib', tests=True)
126 add_package(packages, 'quarantine', tests=True)
125 add_package(packages, 'quarantine', tests=True)
127 add_package(packages, 'scripts')
126 add_package(packages, 'scripts')
128 add_package(packages, 'testing', tests=True)
127 add_package(packages, 'testing', tests=True)
129 add_package(packages, 'testing.plugin', tests=False)
128 add_package(packages, 'testing.plugin', tests=False)
130 add_package(packages, 'utils', tests=True)
129 add_package(packages, 'utils', tests=True)
131 return packages
130 return packages
132
131
133 #---------------------------------------------------------------------------
132 #---------------------------------------------------------------------------
134 # Find package data
133 # Find package data
135 #---------------------------------------------------------------------------
134 #---------------------------------------------------------------------------
136
135
137 def find_package_data():
136 def find_package_data():
138 """
137 """
139 Find IPython's package_data.
138 Find IPython's package_data.
140 """
139 """
141 # This is not enough for these things to appear in an sdist.
140 # This is not enough for these things to appear in an sdist.
142 # We need to muck with the MANIFEST to get this to work
141 # We need to muck with the MANIFEST to get this to work
143 package_data = {
142 package_data = {
144 'IPython.config.userconfig' : ['*'],
143 'IPython.config.userconfig' : ['*'],
145 'IPython.testing' : ['*.txt']
144 'IPython.testing' : ['*.txt']
146 }
145 }
147 return package_data
146 return package_data
148
147
149
148
150 #---------------------------------------------------------------------------
149 #---------------------------------------------------------------------------
151 # Find data files
150 # Find data files
152 #---------------------------------------------------------------------------
151 #---------------------------------------------------------------------------
153
152
154 def make_dir_struct(tag,base,out_base):
153 def make_dir_struct(tag,base,out_base):
155 """Make the directory structure of all files below a starting dir.
154 """Make the directory structure of all files below a starting dir.
156
155
157 This is just a convenience routine to help build a nested directory
156 This is just a convenience routine to help build a nested directory
158 hierarchy because distutils is too stupid to do this by itself.
157 hierarchy because distutils is too stupid to do this by itself.
159
158
160 XXX - this needs a proper docstring!
159 XXX - this needs a proper docstring!
161 """
160 """
162
161
163 # we'll use these a lot below
162 # we'll use these a lot below
164 lbase = len(base)
163 lbase = len(base)
165 pathsep = os.path.sep
164 pathsep = os.path.sep
166 lpathsep = len(pathsep)
165 lpathsep = len(pathsep)
167
166
168 out = []
167 out = []
169 for (dirpath,dirnames,filenames) in os.walk(base):
168 for (dirpath,dirnames,filenames) in os.walk(base):
170 # we need to strip out the dirpath from the base to map it to the
169 # we need to strip out the dirpath from the base to map it to the
171 # output (installation) path. This requires possibly stripping the
170 # output (installation) path. This requires possibly stripping the
172 # path separator, because otherwise pjoin will not work correctly
171 # path separator, because otherwise pjoin will not work correctly
173 # (pjoin('foo/','/bar') returns '/bar').
172 # (pjoin('foo/','/bar') returns '/bar').
174
173
175 dp_eff = dirpath[lbase:]
174 dp_eff = dirpath[lbase:]
176 if dp_eff.startswith(pathsep):
175 if dp_eff.startswith(pathsep):
177 dp_eff = dp_eff[lpathsep:]
176 dp_eff = dp_eff[lpathsep:]
178 # The output path must be anchored at the out_base marker
177 # The output path must be anchored at the out_base marker
179 out_path = pjoin(out_base,dp_eff)
178 out_path = pjoin(out_base,dp_eff)
180 # Now we can generate the final filenames. Since os.walk only produces
179 # Now we can generate the final filenames. Since os.walk only produces
181 # filenames, we must join back with the dirpath to get full valid file
180 # filenames, we must join back with the dirpath to get full valid file
182 # paths:
181 # paths:
183 pfiles = [pjoin(dirpath,f) for f in filenames]
182 pfiles = [pjoin(dirpath,f) for f in filenames]
184 # Finally, generate the entry we need, which is a triple of (tag,output
183 # Finally, generate the entry we need, which is a triple of (tag,output
185 # path, files) for use as a data_files parameter in install_data.
184 # path, files) for use as a data_files parameter in install_data.
186 out.append((tag,out_path,pfiles))
185 out.append((tag,out_path,pfiles))
187
186
188 return out
187 return out
189
188
190
189
191 def find_data_files():
190 def find_data_files():
192 """
191 """
193 Find IPython's data_files.
192 Find IPython's data_files.
194
193
195 Most of these are docs.
194 Most of these are docs.
196 """
195 """
197
196
198 docdirbase = pjoin('share', 'doc', 'ipython')
197 docdirbase = pjoin('share', 'doc', 'ipython')
199 manpagebase = pjoin('share', 'man', 'man1')
198 manpagebase = pjoin('share', 'man', 'man1')
200
199
201 # Simple file lists can be made by hand
200 # Simple file lists can be made by hand
202 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
201 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
203 igridhelpfiles = filter(isfile, glob(pjoin('IPython','extensions','igrid_help.*')))
202 igridhelpfiles = filter(isfile, glob(pjoin('IPython','extensions','igrid_help.*')))
204
203
205 # For nested structures, use the utility above
204 # For nested structures, use the utility above
206 example_files = make_dir_struct(
205 example_files = make_dir_struct(
207 'data',
206 'data',
208 pjoin('docs','examples'),
207 pjoin('docs','examples'),
209 pjoin(docdirbase,'examples')
208 pjoin(docdirbase,'examples')
210 )
209 )
211 manual_files = make_dir_struct(
210 manual_files = make_dir_struct(
212 'data',
211 'data',
213 pjoin('docs','dist'),
212 pjoin('docs','dist'),
214 pjoin(docdirbase,'manual')
213 pjoin(docdirbase,'manual')
215 )
214 )
216
215
217 # And assemble the entire output list
216 # And assemble the entire output list
218 data_files = [ ('data',manpagebase, manpages),
217 data_files = [ ('data',manpagebase, manpages),
219 ('data',pjoin(docdirbase,'extensions'),igridhelpfiles),
218 ('data',pjoin(docdirbase,'extensions'),igridhelpfiles),
220 ] + manual_files + example_files
219 ] + manual_files + example_files
221
220
222 ## import pprint # dbg
221 ## import pprint # dbg
223 ## print '*'*80
222 ## print '*'*80
224 ## print 'data files'
223 ## print 'data files'
225 ## pprint.pprint(data_files)
224 ## pprint.pprint(data_files)
226 ## print '*'*80
225 ## print '*'*80
227
226
228 return data_files
227 return data_files
229
228
230
229
231 def make_man_update_target(manpage):
230 def make_man_update_target(manpage):
232 """Return a target_update-compliant tuple for the given manpage.
231 """Return a target_update-compliant tuple for the given manpage.
233
232
234 Parameters
233 Parameters
235 ----------
234 ----------
236 manpage : string
235 manpage : string
237 Name of the manpage, must include the section number (trailing number).
236 Name of the manpage, must include the section number (trailing number).
238
237
239 Example
238 Example
240 -------
239 -------
241
240
242 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
241 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
243 ('docs/man/ipython.1.gz',
242 ('docs/man/ipython.1.gz',
244 ['docs/man/ipython.1'],
243 ['docs/man/ipython.1'],
245 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
244 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
246 """
245 """
247 man_dir = pjoin('docs', 'man')
246 man_dir = pjoin('docs', 'man')
248 manpage_gz = manpage + '.gz'
247 manpage_gz = manpage + '.gz'
249 manpath = pjoin(man_dir, manpage)
248 manpath = pjoin(man_dir, manpage)
250 manpath_gz = pjoin(man_dir, manpage_gz)
249 manpath_gz = pjoin(man_dir, manpage_gz)
251 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
250 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
252 locals() )
251 locals() )
253 return (manpath_gz, [manpath], gz_cmd)
252 return (manpath_gz, [manpath], gz_cmd)
254
253
255 #---------------------------------------------------------------------------
254 #---------------------------------------------------------------------------
256 # Find scripts
255 # Find scripts
257 #---------------------------------------------------------------------------
256 #---------------------------------------------------------------------------
258
257
259 def find_scripts():
258 def find_scripts():
260 """
259 """
261 Find IPython's scripts.
260 Find IPython's scripts.
262 """
261 """
263 kernel_scripts = pjoin('IPython','kernel','scripts')
262 kernel_scripts = pjoin('IPython','kernel','scripts')
264 main_scripts = pjoin('IPython','scripts')
263 main_scripts = pjoin('IPython','scripts')
265 scripts = [pjoin(kernel_scripts, 'ipengine'),
264 scripts = [pjoin(kernel_scripts, 'ipengine'),
266 pjoin(kernel_scripts, 'ipcontroller'),
265 pjoin(kernel_scripts, 'ipcontroller'),
267 pjoin(kernel_scripts, 'ipcluster'),
266 pjoin(kernel_scripts, 'ipcluster'),
268 pjoin(main_scripts, 'ipython'),
267 pjoin(main_scripts, 'ipython'),
269 pjoin(main_scripts, 'ipythonx'),
268 pjoin(main_scripts, 'ipythonx'),
270 pjoin(main_scripts, 'ipython-wx'),
269 pjoin(main_scripts, 'ipython-wx'),
271 pjoin(main_scripts, 'pycolor'),
270 pjoin(main_scripts, 'pycolor'),
272 pjoin(main_scripts, 'irunner'),
271 pjoin(main_scripts, 'irunner'),
273 pjoin(main_scripts, 'iptest')
272 pjoin(main_scripts, 'iptest')
274 ]
273 ]
275
274
276 # Script to be run by the windows binary installer after the default setup
275 # Script to be run by the windows binary installer after the default setup
277 # routine, to add shortcuts and similar windows-only things. Windows
276 # routine, to add shortcuts and similar windows-only things. Windows
278 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
277 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
279 # doesn't find them.
278 # doesn't find them.
280 if 'bdist_wininst' in sys.argv:
279 if 'bdist_wininst' in sys.argv:
281 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
280 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
282 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
281 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
283 sys.exit(1)
282 sys.exit(1)
284 scripts.append(pjoin('scripts','ipython_win_post_install.py'))
283 scripts.append(pjoin('scripts','ipython_win_post_install.py'))
285
284
286 return scripts
285 return scripts
287
286
288 #---------------------------------------------------------------------------
287 #---------------------------------------------------------------------------
289 # Verify all dependencies
288 # Verify all dependencies
290 #---------------------------------------------------------------------------
289 #---------------------------------------------------------------------------
291
290
292 def check_for_dependencies():
291 def check_for_dependencies():
293 """Check for IPython's dependencies.
292 """Check for IPython's dependencies.
294
293
295 This function should NOT be called if running under setuptools!
294 This function should NOT be called if running under setuptools!
296 """
295 """
297 from setupext.setupext import (
296 from setupext.setupext import (
298 print_line, print_raw, print_status, print_message,
297 print_line, print_raw, print_status, print_message,
299 check_for_zopeinterface, check_for_twisted,
298 check_for_zopeinterface, check_for_twisted,
300 check_for_foolscap, check_for_pyopenssl,
299 check_for_foolscap, check_for_pyopenssl,
301 check_for_sphinx, check_for_pygments,
300 check_for_sphinx, check_for_pygments,
302 check_for_nose, check_for_pexpect
301 check_for_nose, check_for_pexpect
303 )
302 )
304 print_line()
303 print_line()
305 print_raw("BUILDING IPYTHON")
304 print_raw("BUILDING IPYTHON")
306 print_status('python', sys.version)
305 print_status('python', sys.version)
307 print_status('platform', sys.platform)
306 print_status('platform', sys.platform)
308 if sys.platform == 'win32':
307 if sys.platform == 'win32':
309 print_status('Windows version', sys.getwindowsversion())
308 print_status('Windows version', sys.getwindowsversion())
310
309
311 print_raw("")
310 print_raw("")
312 print_raw("OPTIONAL DEPENDENCIES")
311 print_raw("OPTIONAL DEPENDENCIES")
313
312
314 check_for_zopeinterface()
313 check_for_zopeinterface()
315 check_for_twisted()
314 check_for_twisted()
316 check_for_foolscap()
315 check_for_foolscap()
317 check_for_pyopenssl()
316 check_for_pyopenssl()
318 check_for_sphinx()
317 check_for_sphinx()
319 check_for_pygments()
318 check_for_pygments()
320 check_for_nose()
319 check_for_nose()
321 check_for_pexpect()
320 check_for_pexpect()
General Comments 0
You need to be logged in to leave comments. Login now