~ubuntu-branches/ubuntu/utopic/scons/utopic-proposed

« back to all changes in this revision

Viewing changes to script/scons

  • Committer: Bazaar Package Importer
  • Author(s): Mark Brown
  • Date: 2004-08-24 08:57:22 UTC
  • mfrom: (0.2.1 upstream) (1.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040824085722-hfk4f0pjbyu0ebxv
Tags: 0.96.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#
3
3
# SCons - a Software Constructor
4
4
#
5
 
# Copyright (c) 2001, 2002 Steven Knight
 
5
# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
6
6
#
7
7
# Permission is hereby granted, free of charge, to any person obtaining
8
8
# a copy of this software and associated documentation files (the
24
24
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
25
#
26
26
 
27
 
__revision__ = "src/script/scons.py 0.D006 2002/03/28 02:47:47 software"
28
 
 
 
27
__revision__ = "/home/scons/scons/branch.0/baseline/src/script/scons.py 0.96.1.D001 2004/08/23 09:55:29 knight"
 
28
 
 
29
__version__ = "0.96.1"
 
30
 
 
31
__build__ = "D001"
 
32
 
 
33
__buildsys__ = "casablanca"
 
34
 
 
35
__date__ = "2004/08/23 09:55:29"
 
36
 
 
37
__developer__ = "knight"
 
38
 
 
39
import os
 
40
import os.path
29
41
import sys
30
 
import os.path
31
 
import os
 
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
##############################################################################
32
51
 
33
52
# Strip the script directory from sys.path() so on case-insensitive
34
53
# (WIN32) systems Python doesn't think that the "scons" script is the
37
56
# followed by generic) so we pick up the right version of the build
38
57
# engine modules if they're in either directory.
39
58
 
40
 
selfdir = os.path.abspath(sys.argv[0])
41
 
if selfdir in sys.path:
42
 
    sys.path.remove(selfdir)
 
59
script_dir = sys.path[0]
 
60
 
 
61
if script_dir in sys.path:
 
62
    sys.path.remove(script_dir)
43
63
 
44
64
libs = []
45
65
 
46
66
if os.environ.has_key("SCONS_LIB_DIR"):
47
67
    libs.append(os.environ["SCONS_LIB_DIR"])
48
68
 
 
69
local = 'scons-local-' + __version__
 
70
if script_dir:
 
71
    local = os.path.join(script_dir, local)
 
72
libs.append(local)
 
73
 
 
74
scons_version = 'scons-%s' % __version__
 
75
 
 
76
prefs = []
 
77
 
49
78
if sys.platform == 'win32':
50
 
    libs.extend([ os.path.join(sys.prefix, 'SCons-0.06'),
51
 
                  os.path.join(sys.prefix, 'SCons') ])
 
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'))
52
83
else:
53
 
    prefs = []
54
 
 
55
 
    _bin = os.path.join('', 'bin')
56
 
    _usr = os.path.join('', 'usr')
57
 
    _usr_local = os.path.join('', 'usr', 'local')
58
 
 
59
 
    script_dir = sys.path[0]
60
 
 
 
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.
61
87
    if script_dir == 'bin':
 
88
        # script_dir is `pwd`/bin;
 
89
        # check `pwd`/lib/scons*.
62
90
        prefs.append(os.getcwd())
63
91
    else:
64
92
        if script_dir == '.' or script_dir == '':
65
93
            script_dir = os.getcwd()
66
 
        if script_dir[-len(_bin):] == _bin:
67
 
            prefs.append(script_dir[:-len(_bin)])
 
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)
68
99
 
69
 
    if sys.prefix[-len(_usr):] == _usr:
70
 
        prefs.append(sys.prefix)
71
 
        prefs.append(os.path.join(sys.prefix, "local"))
72
 
    elif sys.prefix[-len(_usr_local):] == _usr_local:
73
 
        _local = os.path.join('', 'local')
74
 
        prefs.append(sys.prefix[:-len(_local)])
75
 
        prefs.append(sys.prefix)
 
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)
76
119
    else:
 
120
        # sys.prefix is /foo (ends in neither /usr or /local);
 
121
        # check only /foo/lib/scons*.
77
122
        prefs.append(sys.prefix)
78
123
 
79
 
    libs.extend(map(lambda x: os.path.join(x, 'lib', 'scons-0.06'), prefs))
80
 
    libs.extend(map(lambda x: os.path.join(x, 'lib', 'scons'), prefs))
81
 
 
82
 
sys.path = libs + sys.path[1:]
 
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
# Look first for 'scons-__version__' in all of our preference libs,
 
133
# then for 'scons'.
 
134
libs.extend(map(lambda x: os.path.join(x, scons_version), prefs))
 
135
libs.extend(map(lambda x: os.path.join(x, 'scons'), prefs))
 
136
 
 
137
sys.path = libs + sys.path
 
138
 
 
139
##############################################################################
 
140
# END STANDARD SCons SCRIPT HEADER
 
141
##############################################################################
83
142
 
84
143
import SCons.Script
85
144
SCons.Script.main()