Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Side by Side Diff: scons-2.0.1/setup.py

Issue 6711079: Added an unmodified copy of SCons to third_party. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/third_party/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scons-2.0.1/setup.cfg ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #
2 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The S Cons Foundation
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 __revision__ = "src/setup.py 5134 2010/08/16 23:02:40 bdeegan"
24
25 import os
26 import os.path
27 import stat
28 import sys
29
30 Version = "2.0.1"
31
32 man_pages = [
33 'scons.1',
34 'sconsign.1',
35 'scons-time.1',
36 ]
37
38 (head, tail) = os.path.split(sys.argv[0])
39
40 if head:
41 os.chdir(head)
42 sys.argv[0] = tail
43
44 is_win32 = 0
45 if not sys.platform == 'win32':
46 try:
47 if sys.argv[1] == 'bdist_wininst':
48 is_win32 = 1
49 except IndexError:
50 pass
51 else:
52 is_win32 = 1
53
54 try:
55 import distutils
56 import distutils.core
57 import distutils.command.install
58 import distutils.command.install_data
59 import distutils.command.install_lib
60 import distutils.command.install_scripts
61 import distutils.command.build_scripts
62 except ImportError:
63 sys.stderr.write("""Could not import distutils.
64
65 Building or installing SCons from this package requires that the Python
66 distutils be installed. See the README or README.txt file from this
67 package for instructions on where to find distutils for installation on
68 your system, or on how to install SCons from a different package.
69 """)
70 sys.exit(1)
71
72 _install = distutils.command.install.install
73 _install_data = distutils.command.install_data.install_data
74 _install_lib = distutils.command.install_lib.install_lib
75 _install_scripts = distutils.command.install_scripts.install_scripts
76 _build_scripts = distutils.command.build_scripts.build_scripts
77
78 class _options(object):
79 pass
80
81 Options = _options()
82
83 Installed = []
84
85 def set_explicitly(name, args):
86 """
87 Return if the installation directory was set explicitly by the
88 user on the command line. This is complicated by the fact that
89 "install --install-lib=/foo" gets turned into "install_lib
90 --install-dir=/foo" internally.
91 """
92 if args[0] == "install_" + name:
93 s = "--install-dir="
94 else:
95 # The command is something else (usually "install")
96 s = "--install-%s=" % name
97 set = 0
98 length = len(s)
99 for a in args[1:]:
100 if a[:length] == s:
101 set = 1
102 break
103 return set
104
105 class install(_install):
106 user_options = _install.user_options + [
107 ('no-scons-script', None,
108 "don't install 'scons', only install 'scons-%s'" % Version) ,
109 ('no-version-script', None,
110 "don't install 'scons-%s', only install 'scons'" % Version) ,
111 ('install-bat', None,
112 "install 'scons.bat' script"),
113 ('no-install-bat', None,
114 "do not install 'scons.bat' script"),
115 ('install-man', None,
116 "install SCons man pages"),
117 ('no-install-man', None,
118 "do not install SCons man pages"),
119 ('standard-lib', None,
120 "install SCons library in standard Python location"),
121 ('standalone-lib', None,
122 "install SCons library in separate standalone directory"),
123 ('version-lib', None,
124 "install SCons library in version-numbered directory"),
125 ]
126 boolean_options = _install.boolean_options + [
127 'no-scons-script',
128 'no-version-script',
129 'install-bat',
130 'no-install-bat',
131 'install-man',
132 'no-install-man',
133 'standard-lib',
134 'standalone-lib',
135 'version-lib'
136 ]
137
138 if hasattr(os, 'symlink'):
139 user_options.append(
140 ('hardlink-scons', None,
141 "hard link 'scons' to the version-numbered script, don't ma ke a separate 'scons' copy"),
142 )
143 boolean_options.append('hardlink-script')
144
145 if hasattr(os, 'symlink'):
146 user_options.append(
147 ('symlink-scons', None,
148 "make 'scons' a symbolic link to the version-numbered scrip t, don't make a separate 'scons' copy"),
149 )
150 boolean_options.append('symlink-script')
151
152 def initialize_options(self):
153 _install.initialize_options(self)
154 self.no_scons_script = 0
155 self.no_version_script = 0
156 self.install_bat = 0
157 self.no_install_bat = not is_win32
158 self.install_man = 0
159 self.no_install_man = is_win32
160 self.standard_lib = 0
161 self.standalone_lib = 0
162 self.version_lib = 0
163 self.hardlink_scons = 0
164 self.symlink_scons = 0
165 # Don't warn about having to put the library directory in the
166 # search path.
167 self.warn_dir = 0
168
169 def finalize_options(self):
170 _install.finalize_options(self)
171 if self.install_bat:
172 Options.install_bat = 1
173 else:
174 Options.install_bat = not self.no_install_bat
175 if self.install_man:
176 Options.install_man = 1
177 else:
178 Options.install_man = not self.no_install_man
179 Options.standard_lib = self.standard_lib
180 Options.standalone_lib = self.standalone_lib
181 Options.version_lib = self.version_lib
182 Options.install_scons_script = not self.no_scons_script
183 Options.install_version_script = not self.no_version_script
184 Options.hardlink_scons = self.hardlink_scons
185 Options.symlink_scons = self.symlink_scons
186
187 def get_scons_prefix(libdir, is_win32):
188 """
189 Return the right prefix for SCons library installation. Find
190 this by starting with the library installation directory
191 (.../site-packages, most likely) and crawling back up until we reach
192 a directory name beginning with "python" (or "Python").
193 """
194 drive, head = os.path.splitdrive(libdir)
195 while head:
196 if head == os.sep:
197 break
198 head, tail = os.path.split(head)
199 if tail.lower()[:6] == "python":
200 # Found the Python library directory...
201 if is_win32:
202 # ...on Win32 systems, "scons" goes in the directory:
203 # C:\PythonXX => C:\PythonXX\scons
204 return os.path.join(drive + head, tail)
205 else:
206 # ...on other systems, "scons" goes above the directory:
207 # /usr/lib/pythonX.X => /usr/lib/scons
208 return os.path.join(drive + head)
209 return libdir
210
211 def force_to_usr_local(self):
212 """
213 A hack to decide if we need to "force" the installation directories
214 to be under /usr/local. This is because Mac Os X Tiger and
215 Leopard, by default, put the libraries and scripts in their own
216 directories under /Library or /System/Library.
217 """
218 return (sys.platform[:6] == 'darwin' and
219 (self.install_dir[:9] == '/Library/' or
220 self.install_dir[:16] == '/System/Library/'))
221
222 class install_lib(_install_lib):
223 def finalize_options(self):
224 _install_lib.finalize_options(self)
225 if force_to_usr_local(self):
226 self.install_dir = '/usr/local/lib'
227 args = self.distribution.script_args
228 if not set_explicitly("lib", args):
229 # They didn't explicitly specify the installation
230 # directory for libraries...
231 is_win32 = sys.platform == "win32" or args[0] == 'bdist_wininst'
232 prefix = get_scons_prefix(self.install_dir, is_win32)
233 if Options.standalone_lib:
234 # ...but they asked for a standalone directory.
235 self.install_dir = os.path.join(prefix, "scons")
236 elif Options.version_lib or not Options.standard_lib:
237 # ...they asked for a version-specific directory,
238 # or they get it by default.
239 self.install_dir = os.path.join(prefix, "scons-%s" % Version)
240
241 msg = "Installed SCons library modules into %s" % self.install_dir
242 Installed.append(msg)
243
244 class install_scripts(_install_scripts):
245 def finalize_options(self):
246 _install_scripts.finalize_options(self)
247 if force_to_usr_local(self):
248 self.install_dir = '/usr/local/bin'
249 self.build_dir = os.path.join('build', 'scripts')
250 msg = "Installed SCons scripts into %s" % self.install_dir
251 Installed.append(msg)
252
253 def do_nothing(self, *args, **kw):
254 pass
255
256 def hardlink_scons(self, src, dst, ver):
257 try: os.unlink(dst)
258 except OSError: pass
259 os.link(ver, dst)
260
261 def symlink_scons(self, src, dst, ver):
262 try: os.unlink(dst)
263 except OSError: pass
264 os.symlink(os.path.split(ver)[1], dst)
265
266 def copy_scons(self, src, dst, *args):
267 try: os.unlink(dst)
268 except OSError: pass
269 self.copy_file(src, dst)
270 self.outfiles.append(dst)
271
272 def report(self, msg, args):
273 # Wrapper around self.announce, used by older distutils versions.
274 self.announce(msg % args)
275
276 def run(self):
277 # This "skip_build/build_scripts" block is cut-and-paste from
278 # distutils.
279 if not self.skip_build:
280 self.run_command('build_scripts')
281
282 # Custom SCons installation stuff.
283 if Options.hardlink_scons:
284 create_basename_script = self.hardlink_scons
285 elif Options.symlink_scons:
286 create_basename_script = self.symlink_scons
287 elif Options.install_scons_script:
288 create_basename_script = self.copy_scons
289 else:
290 create_basename_script = self.do_nothing
291
292 if Options.install_version_script:
293 create_version_script = self.copy_scons
294 else:
295 create_version_script = self.do_nothing
296
297 inputs = self.get_inputs()
298 bat_scripts = [x for x in inputs if x[-4:] == '.bat']
299 non_bat_scripts = [x for x in inputs if x[-4:] != '.bat']
300
301 self.outfiles = []
302 self.mkpath(self.install_dir)
303
304 for src in non_bat_scripts:
305 base = os.path.basename(src)
306 scons = os.path.join(self.install_dir, base)
307 scons_ver = scons + '-' + Version
308 create_version_script(src, scons_ver)
309 create_basename_script(src, scons, scons_ver)
310
311 if Options.install_bat:
312 if is_win32:
313 bat_install_dir = get_scons_prefix(self.install_dir, is_win32)
314 else:
315 bat_install_dir = self.install_dir
316 for src in bat_scripts:
317 scons_bat = os.path.join(bat_install_dir, 'scons.bat')
318 scons_version_bat = os.path.join(bat_install_dir,
319 'scons-' + Version + '.bat')
320 self.copy_scons(src, scons_bat)
321 self.copy_scons(src, scons_version_bat)
322
323 # This section is cut-and-paste from distutils, modulo being
324 # able
325 if os.name == 'posix':
326 try: report = distutils.log.info
327 except AttributeError: report = self.report
328 # Set the executable bits (owner, group, and world) on
329 # all the scripts we just installed.
330 for file in self.get_outputs():
331 if self.dry_run:
332 report("changing mode of %s", file)
333 else:
334 mode = ((os.stat(file)[stat.ST_MODE]) | 0555) & 07777
335 report("changing mode of %s", file)
336 os.chmod(file, mode)
337
338 class build_scripts(_build_scripts):
339 def finalize_options(self):
340 _build_scripts.finalize_options(self)
341 self.build_dir = os.path.join('build', 'scripts')
342
343 class install_data(_install_data):
344 def initialize_options(self):
345 _install_data.initialize_options(self)
346 def finalize_options(self):
347 _install_data.finalize_options(self)
348 if force_to_usr_local(self):
349 self.install_dir = '/usr/local'
350 if Options.install_man:
351 if is_win32:
352 dir = 'Doc'
353 else:
354 dir = os.path.join('man', 'man1')
355 self.data_files = [(dir, man_pages)]
356 man_dir = os.path.join(self.install_dir, dir)
357 msg = "Installed SCons man pages into %s" % man_dir
358 Installed.append(msg)
359 else:
360 self.data_files = []
361
362 description = "Open Source next-generation build tool."
363
364 long_description = """Open Source next-generation build tool.
365 Improved, cross-platform substitute for the classic Make
366 utility. In short, SCons is an easier, more reliable
367 and faster way to build software."""
368
369 scripts = [
370 'script/scons',
371 'script/sconsign',
372 'script/scons-time',
373
374 # We include scons.bat in the list of scripts, even on UNIX systems,
375 # because we provide an option to allow it be installed explicitly,
376 # for example if you're installing from UNIX on a share that's
377 # accessible to Windows and you want the scons.bat.
378 'script/scons.bat',
379 ]
380
381 #if is_win32:
382 # scripts = scripts + [
383 # 'script/scons-post-install.py'
384 # ]
385
386 arguments = {
387 'name' : "scons",
388 'version' : Version,
389 'description' : description,
390 'long_description' : long_description,
391 'author' : 'Steven Knight',
392 'author_email' : 'knight@baldmt.com',
393 'url' : "http://www.scons.org/",
394 'packages' : ["SCons",
395 "SCons.compat",
396 "SCons.Node",
397 "SCons.Options",
398 "SCons.Platform",
399 "SCons.Scanner",
400 "SCons.Script",
401 "SCons.Tool",
402 "SCons.Tool.MSCommon",
403 "SCons.Tool.packaging",
404 "SCons.Variables",
405 ],
406 'package_dir' : {'' : 'engine'},
407 'data_files' : [('man/man1', man_pages)],
408 'scripts' : scripts,
409 'cmdclass' : {'install' : install,
410 'install_lib' : install_lib,
411 'install_data' : install_data,
412 'install_scripts' : install_scripts,
413 'build_scripts' : build_scripts}
414 }
415
416 distutils.core.setup(**arguments)
417
418 if Installed:
419 print '\n'.join(Installed)
420
421 # Local Variables:
422 # tab-width:4
423 # indent-tabs-mode:nil
424 # End:
425 # vim: set expandtab tabstop=4 shiftwidth=4:
OLDNEW
« no previous file with comments | « scons-2.0.1/setup.cfg ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698