Added fix for TeX includes with same name as subdirs.
[scons.git] / bootstrap.py
index 165c081d4405c88d261fbde4bf1754bc63b2965d..37e8e70722f5796cf73bda088b494ca5dfe77e1f 100644 (file)
@@ -23,7 +23,6 @@
 
 import os
 import os.path
-import string
 import sys
 
 __doc__ = """bootstrap.py
@@ -80,18 +79,14 @@ executing it for the full build of all the packages, as specified in our
 local SConstruct file.
 """
 
-bootstrap_dir = 'bootstrap'
 try:
-    script_dir = os.path.split(__file__)[0]
+    script_dir = os.path.abspath(os.path.dirname(__file__))
 except NameError:
     # Pre-2.3 versions of Python don't have __file__.
-    script_dir = os.path.split(sys.argv[0])[0]
-    if not script_dir:
-        script_dir = os.getcwd()
-    elif not os.path.is_abs(script_dir):
-        script_dir = os.path.join(os.getcwd(), script_dir)
-if script_dir:
-    bootstrap_dir = os.path.join(script_dir, bootstrap_dir)
+    script_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
+
+bootstrap_dir = os.path.join(script_dir, 'bootstrap')
+
 pass_through_args = []
 update_only = None
 
@@ -102,8 +97,7 @@ def must_copy(dst, src):
         return 1
     return open(dst, 'rb').read() != open(src, 'rb').read()
 
-search = [os.path.dirname(sys.argv[0])]
-if search[0] == '': search[0] = '.'
+search = [script_dir]
 
 # Note:  We don't use the getopt module to process the command-line
 # arguments because we'd have to teach it about all of the SCons options.
@@ -176,15 +170,15 @@ def find(file, search=search):
         if os.path.exists(f):
             return os.path.normpath(f)
     sys.stderr.write("could not find `%s' in search path:\n" % file)
-    sys.stderr.write("\t" + string.join(search, "\n\t") + "\n")
+    sys.stderr.write("\t" + "\n\t".join(search) + "\n")
     sys.exit(2)
 
 scons_py = os.path.join('src', 'script', 'scons.py')
 src_engine = os.path.join('src', 'engine')
 MANIFEST_in = find(os.path.join(src_engine, 'MANIFEST.in'))
 
-files = [ scons_py ] + map(lambda x: os.path.join(src_engine, x[:-1]),
-                           open(MANIFEST_in).readlines())
+files = [ scons_py ] + [os.path.join(src_engine, x[:-1])
+                        for x in open(MANIFEST_in).readlines()]
 
 for file in files:
     src = find(file)
@@ -201,11 +195,11 @@ if update_only:
     sys.exit(0)
 
 args = [
-            os.path.split(sys.executable)[1],
+            sys.executable,
             os.path.join(bootstrap_dir, scons_py)
        ] + pass_through_args
 
-sys.stdout.write(string.join(args, " ") + '\n')
+sys.stdout.write(" ".join(args) + '\n')
 sys.stdout.flush()
 
 os.environ['SCONS_LIB_DIR'] = os.path.join(bootstrap_dir, src_engine)