OLD | NEW |
(Empty) | |
| 1 #! /usr/bin/env python |
| 2 # |
| 3 # SCons - a Software Constructor |
| 4 # |
| 5 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The S
Cons 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__ = "src/script/scons.py 5134 2010/08/16 23:02:40 bdeegan" |
| 28 |
| 29 __version__ = "2.0.1" |
| 30 |
| 31 __build__ = "r5134" |
| 32 |
| 33 __buildsys__ = "cooldog" |
| 34 |
| 35 __date__ = "2010/08/16 23:02:40" |
| 36 |
| 37 __developer__ = "bdeegan" |
| 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 |
| 60 # Check to see if the python version is > 3.0 which is currently unsupported |
| 61 # If so exit with error message |
| 62 try: |
| 63 if sys.version_info >= (3,0,0): |
| 64 msg = "scons: *** SCons version %s does not run under Python version %s.
\n" |
| 65 sys.stderr.write(msg % (__version__, sys.version.split()[0])) |
| 66 sys.exit(1) |
| 67 except AttributeError: |
| 68 # Pre-1.6 Python has no sys.version_info |
| 69 # No need to check version as we then know the version is < 3.0.0 and suppor
ted |
| 70 pass |
| 71 |
| 72 script_dir = sys.path[0] |
| 73 |
| 74 if script_dir in sys.path: |
| 75 sys.path.remove(script_dir) |
| 76 |
| 77 libs = [] |
| 78 |
| 79 if "SCONS_LIB_DIR" in os.environ: |
| 80 libs.append(os.environ["SCONS_LIB_DIR"]) |
| 81 |
| 82 local_version = 'scons-local-' + __version__ |
| 83 local = 'scons-local' |
| 84 if script_dir: |
| 85 local_version = os.path.join(script_dir, local_version) |
| 86 local = os.path.join(script_dir, local) |
| 87 libs.append(os.path.abspath(local_version)) |
| 88 libs.append(os.path.abspath(local)) |
| 89 |
| 90 scons_version = 'scons-%s' % __version__ |
| 91 |
| 92 prefs = [] |
| 93 |
| 94 if sys.platform == 'win32': |
| 95 # sys.prefix is (likely) C:\Python*; |
| 96 # check only C:\Python*. |
| 97 prefs.append(sys.prefix) |
| 98 prefs.append(os.path.join(sys.prefix, 'Lib', 'site-packages')) |
| 99 else: |
| 100 # On other (POSIX) platforms, things are more complicated due to |
| 101 # the variety of path names and library locations. Try to be smart |
| 102 # about it. |
| 103 if script_dir == 'bin': |
| 104 # script_dir is `pwd`/bin; |
| 105 # check `pwd`/lib/scons*. |
| 106 prefs.append(os.getcwd()) |
| 107 else: |
| 108 if script_dir == '.' or script_dir == '': |
| 109 script_dir = os.getcwd() |
| 110 head, tail = os.path.split(script_dir) |
| 111 if tail == "bin": |
| 112 # script_dir is /foo/bin; |
| 113 # check /foo/lib/scons*. |
| 114 prefs.append(head) |
| 115 |
| 116 head, tail = os.path.split(sys.prefix) |
| 117 if tail == "usr": |
| 118 # sys.prefix is /foo/usr; |
| 119 # check /foo/usr/lib/scons* first, |
| 120 # then /foo/usr/local/lib/scons*. |
| 121 prefs.append(sys.prefix) |
| 122 prefs.append(os.path.join(sys.prefix, "local")) |
| 123 elif tail == "local": |
| 124 h, t = os.path.split(head) |
| 125 if t == "usr": |
| 126 # sys.prefix is /foo/usr/local; |
| 127 # check /foo/usr/local/lib/scons* first, |
| 128 # then /foo/usr/lib/scons*. |
| 129 prefs.append(sys.prefix) |
| 130 prefs.append(head) |
| 131 else: |
| 132 # sys.prefix is /foo/local; |
| 133 # check only /foo/local/lib/scons*. |
| 134 prefs.append(sys.prefix) |
| 135 else: |
| 136 # sys.prefix is /foo (ends in neither /usr or /local); |
| 137 # check only /foo/lib/scons*. |
| 138 prefs.append(sys.prefix) |
| 139 |
| 140 temp = [os.path.join(x, 'lib') for x in prefs] |
| 141 temp.extend([os.path.join(x, |
| 142 'lib', |
| 143 'python' + sys.version[:3], |
| 144 'site-packages') for x in prefs]) |
| 145 prefs = temp |
| 146 |
| 147 # Add the parent directory of the current python's library to the |
| 148 # preferences. On SuSE-91/AMD64, for example, this is /usr/lib64, |
| 149 # not /usr/lib. |
| 150 try: |
| 151 libpath = os.__file__ |
| 152 except AttributeError: |
| 153 pass |
| 154 else: |
| 155 # Split /usr/libfoo/python*/os.py to /usr/libfoo/python*. |
| 156 libpath, tail = os.path.split(libpath) |
| 157 # Split /usr/libfoo/python* to /usr/libfoo |
| 158 libpath, tail = os.path.split(libpath) |
| 159 # Check /usr/libfoo/scons*. |
| 160 prefs.append(libpath) |
| 161 |
| 162 try: |
| 163 import pkg_resources |
| 164 except ImportError: |
| 165 pass |
| 166 else: |
| 167 # when running from an egg add the egg's directory |
| 168 try: |
| 169 d = pkg_resources.get_distribution('scons') |
| 170 except pkg_resources.DistributionNotFound: |
| 171 pass |
| 172 else: |
| 173 prefs.append(d.location) |
| 174 |
| 175 # Look first for 'scons-__version__' in all of our preference libs, |
| 176 # then for 'scons'. |
| 177 libs.extend([os.path.join(x, scons_version) for x in prefs]) |
| 178 libs.extend([os.path.join(x, 'scons') for x in prefs]) |
| 179 |
| 180 sys.path = libs + sys.path |
| 181 |
| 182 ############################################################################## |
| 183 # END STANDARD SCons SCRIPT HEADER |
| 184 ############################################################################## |
| 185 |
| 186 if __name__ == "__main__": |
| 187 import SCons.Script |
| 188 # this does all the work, and calls sys.exit |
| 189 # with the proper exit status when done. |
| 190 SCons.Script.main() |
| 191 |
| 192 # Local Variables: |
| 193 # tab-width:4 |
| 194 # indent-tabs-mode:nil |
| 195 # End: |
| 196 # vim: set expandtab tabstop=4 shiftwidth=4: |
OLD | NEW |