root/branches/Carsten_PtrWork2/Tools/scons-local/scons.py

Revision 568, 5.5 kB (checked in by vossg, 2 years ago)

added : scons local (0.96.95)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 #! /usr/bin/env python
2 #
3 # SCons - a Software Constructor
4 #
5 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The SCons Foundation
6 #
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
14 #
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
17 #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #
26
27 __revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/script/scons.py 0.96.95.D002 2007/02/14 11:01:59 knight"
28
29 __version__ = "0.96.95"
30
31 __build__ = "D002"
32
33 __buildsys__ = "roxbury"
34
35 __date__ = "2007/02/14 11:01:59"
36
37 __developer__ = "knight"
38
39 import os
40 import os.path
41 import sys
42
43 ##############################################################################
44 # BEGIN STANDARD SCons SCRIPT HEADER
45 #
46 # This is the cut-and-paste logic so that a self-contained script can
47 # interoperate correctly with different SCons versions and installation
48 # locations for the engine.  If you modify anything in this section, you
49 # should also change other scripts that use this same header.
50 ##############################################################################
51
52 # Strip the script directory from sys.path() so on case-insensitive
53 # (WIN32) systems Python doesn't think that the "scons" script is the
54 # "SCons" package.  Replace it with our own library directories
55 # (version-specific first, in case they installed by hand there,
56 # followed by generic) so we pick up the right version of the build
57 # engine modules if they're in either directory.
58
59 script_dir = sys.path[0]
60
61 if script_dir in sys.path:
62     sys.path.remove(script_dir)
63
64 libs = []
65
66 if os.environ.has_key("SCONS_LIB_DIR"):
67     libs.append(os.environ["SCONS_LIB_DIR"])
68
69 local = 'scons-local-' + __version__
70 if script_dir:
71     local = os.path.join(script_dir, local)
72 libs.append(os.path.abspath(local))
73
74 scons_version = 'scons-%s' % __version__
75
76 prefs = []
77
78 if sys.platform == 'win32':
79     # sys.prefix is (likely) C:\Python*;
80     # check only C:\Python*.
81     prefs.append(sys.prefix)
82     prefs.append(os.path.join(sys.prefix, 'Lib', 'site-packages'))
83 else:
84     # On other (POSIX) platforms, things are more complicated due to
85     # the variety of path names and library locations.  Try to be smart
86     # about it.
87     if script_dir == 'bin':
88         # script_dir is `pwd`/bin;
89         # check `pwd`/lib/scons*.
90         prefs.append(os.getcwd())
91     else:
92         if script_dir == '.' or script_dir == '':
93             script_dir = os.getcwd()
94         head, tail = os.path.split(script_dir)
95         if tail == "bin":
96             # script_dir is /foo/bin;
97             # check /foo/lib/scons*.
98             prefs.append(head)
99
100     head, tail = os.path.split(sys.prefix)
101     if tail == "usr":
102         # sys.prefix is /foo/usr;
103         # check /foo/usr/lib/scons* first,
104         # then /foo/usr/local/lib/scons*.
105         prefs.append(sys.prefix)
106         prefs.append(os.path.join(sys.prefix, "local"))
107     elif tail == "local":
108         h, t = os.path.split(head)
109         if t == "usr":
110             # sys.prefix is /foo/usr/local;
111             # check /foo/usr/local/lib/scons* first,
112             # then /foo/usr/lib/scons*.
113             prefs.append(sys.prefix)
114             prefs.append(head)
115         else:
116             # sys.prefix is /foo/local;
117             # check only /foo/local/lib/scons*.
118             prefs.append(sys.prefix)
119     else:
120         # sys.prefix is /foo (ends in neither /usr or /local);
121         # check only /foo/lib/scons*.
122         prefs.append(sys.prefix)
123
124     temp = map(lambda x: os.path.join(x, 'lib'), prefs)
125     temp.extend(map(lambda x: os.path.join(x,
126                                            'lib',
127                                            'python' + sys.version[:3],
128                                            'site-packages'),
129                            prefs))
130     prefs = temp
131
132     # Add the parent directory of the current python's library to the
133     # preferences.  On SuSE-91/AMD64, for example, this is /usr/lib64,
134     # not /usr/lib.
135     try:
136         libpath = os.__file__
137     except AttributeError:
138         pass
139     else:
140         while libpath:
141             libpath, tail = os.path.split(libpath)
142             if tail[:6] == "python":
143                 break
144         if libpath:
145             # Python library is in /usr/libfoo/python*;
146             # check /usr/libfoo/scons*.
147             prefs.append(libpath)
148
149 # Look first for 'scons-__version__' in all of our preference libs,
150 # then for 'scons'.
151 libs.extend(map(lambda x: os.path.join(x, scons_version), prefs))
152 libs.extend(map(lambda x: os.path.join(x, 'scons'), prefs))
153
154 sys.path = libs + sys.path
155
156 ##############################################################################
157 # END STANDARD SCons SCRIPT HEADER
158 ##############################################################################
159
160 import SCons.Script
161 SCons.Script.main()
Note: See TracBrowser for help on using the browser.