diff options
author | Steven Knight <knight@baldmt.com> | 2003-02-07 07:05:09 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-02-07 07:05:09 (GMT) |
commit | 1e93334baa5bafe099bba0bbb2878cfbc4349ac1 (patch) | |
tree | 73f0208106d249b4b5e5164e42e951f5157ffefc /src/script | |
parent | 4f6a2c926304ee3ea444b6854991489702252c0e (diff) | |
download | SCons-1e93334baa5bafe099bba0bbb2878cfbc4349ac1.zip SCons-1e93334baa5bafe099bba0bbb2878cfbc4349ac1.tar.gz SCons-1e93334baa5bafe099bba0bbb2878cfbc4349ac1.tar.bz2 |
Fix case-sensitive packaging problem on Win32.
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/scons.py | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/src/script/scons.py b/src/script/scons.py index f21a3eb..f128d1d 100644 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -62,36 +62,61 @@ if script_dir: local = os.path.join(script_dir, local) libs.append(local) -if sys.platform == 'win32': - libs.extend([ os.path.join(sys.prefix, 'SCons-%s' % __version__), - os.path.join(sys.prefix, 'SCons') ]) -else: - prefs = [] +scons_version = 'scons-%s' % __version__ - _bin = os.path.join('', 'bin') - _usr = os.path.join('', 'usr') - _usr_local = os.path.join('', 'usr', 'local') +prefs = [] +if sys.platform == 'win32': + # sys.prefix is (likely) C:\Python*; + # check only C:\Python*. + prefs.append(sys.prefix) +else: + # On other (POSIX) platforms, things are more complicated due to + # the variety of path names and library locations. Try to be smart + # about it. if script_dir == 'bin': + # script_dir is `pwd`/bin; + # check `pwd`/lib/scons*. prefs.append(os.getcwd()) else: if script_dir == '.' or script_dir == '': script_dir = os.getcwd() - if script_dir[-len(_bin):] == _bin: - prefs.append(script_dir[:-len(_bin)]) - - if sys.prefix[-len(_usr):] == _usr: - prefs.append(sys.prefix) - prefs.append(os.path.join(sys.prefix, "local")) - elif sys.prefix[-len(_usr_local):] == _usr_local: - _local = os.path.join('', 'local') - prefs.append(sys.prefix[:-len(_local)]) + head, tail = os.path.split(script_dir) + if tail == "bin": + # script_dir is /foo/bin; + # check /foo/lib/scons*. + prefs.append(head) + + head, tail = os.path.split(sys.prefix) + if tail == "usr": + # sys.prefix is /foo/usr; + # check /foo/usr/lib/scons* first, + # then /foo/usr/local/lib/scons*. prefs.append(sys.prefix) + prefs.append(os.path.join(sys.prefix, "local")) + elif tail == "local": + h, t = os.path.split(head) + if t == "usr": + # sys.prefix is /foo/usr/local; + # check /foo/usr/local/lib/scons* first, + # then /foo/usr/lib/scons*. + prefs.append(sys.prefix) + prefs.append(head) + else: + # sys.prefix is /foo/local; + # check only /foo/local/lib/scons*. + prefs.append(sys.prefix) else: + # sys.prefix is /foo (ends in neither /usr or /local); + # check only /foo/lib/scons*. prefs.append(sys.prefix) - libs.extend(map(lambda x: os.path.join(x, 'lib', 'scons-%s' % __version__), prefs)) - libs.extend(map(lambda x: os.path.join(x, 'lib', 'scons'), prefs)) + prefs = map(lambda x: os.path.join(x, 'lib'), prefs) + +# Look first for 'scons-__version__' in all of our preference libs, +# then for 'scons'. +libs.extend(map(lambda x: os.path.join(x, scons_version), prefs)) +libs.extend(map(lambda x: os.path.join(x, 'scons'), prefs)) sys.path = libs + sys.path |