Commits

Steven Knight  committed 3e4fd05

Update the packaging SConscript files to be platform independent.

  • Participants
  • Parent commits 2a1aa56

Comments (0)

Files changed (4)

 INSTALLATION
 ============
 
-Assuming your system satisfies the installation requirements in
-the previous section, install SCons from this package by first
-populating the build/scons/ directory.  (For an easier way to
-install SCons, without having to populate this directory, use the
-scons-{version}.tar.gz or scons-{version}.zip package.)
+Assuming your system satisfies the installation requirements in the
+previous section, install SCons from this package by first populating
+the build/scons/ subdirectory.  (For an easier way to install SCons,
+without having to populate this directory, use the scons-{version}.tar.gz
+or scons-{version}.zip package.)
 
 If you already have an appropriate version of SCons installed on your
 system, populate the build/scons/ directory by running:
 
 If you don't have SCons version 0.96 or later already installed on your
 system, you can use SCons itself to populate the build/scons/ directory
-with a little more typing:
+with a little more typing.  You must first set the SCONS_LIB_DIR
+environment variable to the local src/engine subdirectory, and then
+execute the local src/script/scons.py script to populate the build/scons/
+subdirectory.  You would do this as follows on a Linux or UNIX system
+(using sh or a derivative like bash or ksh):
 
-        $ SCONS_LIB_DIR=`pwd`/src/engine python src/script/scons.py build/scons
+        $ export SCONS_LIB_DIR=`pwd`/src/engine
+        $ python src/script/scons.py build/scons
 
-Either command will populate the build/scons/ directory with the
-necessary files and directory structure to use the Python-standard setup
-script as follows:
+Or as follows on Windows:
+        
+        C:\scons\>set SCONS_LIB_DIR=%cd%\src\engine
+        C:\scons\>python src/script/scons.py build/scons
+
+Either command will populate the build/scons/ directory with the necessary
+files and directory structure to use the Python-standard setup script
+as follows on Linux or UNIX:
 
         # cd build/scons
         # python setup.py install
 
+And on Windows:
+
+        C:\scons\>cd build\scons
+        C:\scons\build\scons>python setup.py install
+
 If this is the first time you are installing SCons on your system,
 the above command will install the scons script in the default system
-script directory (/usr/bin or C:\Python*\Scripts, for example) and the
-build engine in an appropriate stand-alone SCons library directory
+script directory (/usr/bin or C:\Python*\Scripts, for example) and
+the build engine in an appropriate stand-alone SCons library directory
 (/usr/lib/scons or C:\Python*\scons, for example).
 
 Note that, by default, SCons does not install its library in the
 
 Default('.')
 
+SConsignFile()
+
 #
 # An internal "whereis" routine to figure out if a given program
 # is available on this system.
     if os.environ.has_key(key):
         ENV[key] = os.environ[key]
 
-lib_project = os.path.join("lib", project)
-
 cwd_build = os.path.join(os.getcwd(), "build")
 
 test_deb_dir          = os.path.join(cwd_build, "test-deb")
 
 if platform == "win32":
     tar_hflag = ''
-    python_project_subinst_dir = None
+    python_project_subinst_dir = os.path.join("Lib", "site-packages", project)
     project_script_subinst_dir = 'Scripts'
 else:
     tar_hflag = 'h'
-    python_project_subinst_dir = lib_project
+    python_project_subinst_dir = os.path.join("lib", project)
     project_script_subinst_dir = 'bin'
 
 
 # In the original, more complicated packaging scheme, we were going
 # to have separate packages for:
 #
-#	python-scons	only the build engine
-#	scons-script	only the script
-#	scons		the script plus the build engine
+#       python-scons    only the build engine
+#       scons-script    only the script
+#       scons           the script plus the build engine
 #
 # We're now only delivering a single "scons" package, but this is still
 # "built" as two sub-packages (the build engine and the script), so
                             'sconsign.1' : '../doc/man/sconsign.1',
                           },
 
-        'subpkgs'	: [ python_scons, scons_script ],
+        'subpkgs'       : [ python_scons, scons_script ],
 
-        'subinst_dirs'	: {
+        'subinst_dirs'  : {
                              'python-' + project : python_project_subinst_dir,
                              project + '-script' : project_script_subinst_dir,
                            },
                 rpm_files.append(r)
                 if f[-3:] == ".py":
                     rpm_files.append(r + 'c')
-            if isubdir:
-                files = map(lambda x, i=isubdir: os.path.join(i, x), files)
+            files = map(lambda x, i=isubdir: os.path.join(i, x), files)
             dst_files.extend(files)
             for k in sp['filemap'].keys():
                 f = sp['filemap'][k]
 
     def write_src_files(target, source, **kw):
         global src_files
-	src_files.sort()
+        src_files.sort()
         f = open(str(target[0]), 'wb')
         for file in src_files:
             f.write(file + "\n")
         #
         # We'd like to replace the last three lines with the following:
         #
-        #	tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
+        #       tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
         #
         # but that gives heartburn to Cygwin's tar, so work around it
         # with separate zcat-tar-rm commands.
                                          os.path.join(u, pv, x),
                                   src_files)
         env.Command(unpack_tar_gz_files, tar_gz, [
-                    "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version),
+                    Delete(os.path.join(unpack_tar_gz_dir, pkg_version)),
                     "$ZCAT $SOURCES > .temp",
                     "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
-                    "rm -f .temp",
+                    Delete(".temp"),
         ])
 
         #
         #
         dfiles = map(lambda x, d=test_tar_gz_dir: os.path.join(d, x), dst_files)
         env.Command(dfiles, unpack_tar_gz_files, [
-            "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version, 'build'),
-            "rm -rf $TEST_TAR_GZ_DIR",
-            "$PYTHON %s install --prefix=$TEST_TAR_GZ_DIR" % \
+            Delete(os.path.join(unpack_tar_gz_dir, pkg_version, 'build')),
+            Delete("$TEST_TAR_GZ_DIR"),
+            '$PYTHON "%s" install "--prefix=$TEST_TAR_GZ_DIR"' % \
                 os.path.join(unpack_tar_gz_dir, pkg_version, 'setup.py'),
         ])
 
+        #
+        # Generate portage files for submission to Gentoo Linux.
+        #
+        gentoo = os.path.join('build', 'gentoo')
+        ebuild = os.path.join(gentoo, 'scons-%s.ebuild' % version)
+        digest = os.path.join(gentoo, 'files', 'digest-scons-%s' % version)
+        env.Command(ebuild, os.path.join('gentoo', 'scons.ebuild.in'), SCons_revision)
+        def Digestify(target, source, env):
+            import md5
+            def hexdigest(s):
+                """Return a signature as a string of hex characters.
+                """
+                # NOTE:  This routine is a method in the Python 2.0 interface
+                # of the native md5 module, but we want SCons to operate all
+                # the way back to at least Python 1.5.2, which doesn't have it.
+                h = string.hexdigits
+                r = ''
+                for c in s:
+                    i = ord(c)
+                    r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
+                return r
+            src = source[0].rfile()
+            contents = open(str(src)).read()
+            sig = hexdigest(md5.new(contents).digest())
+            bytes = os.stat(str(src))[6]
+            open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig,
+                                                                src.name,
+                                                                bytes))
+        env.Command(digest, tar_gz, Digestify)
+
     if zipit:
 
         distutils_formats.append('zip')
                                src_files)
 
         env.Command(unpack_zip_files, zip, [
-            "rm -rf %s" % os.path.join(unpack_zip_dir, pkg_version),
-            unzipit
+            Delete(os.path.join(unpack_zip_dir, pkg_version)),
+            unzipit,
         ])
 
         #
         #
         dfiles = map(lambda x, d=test_zip_dir: os.path.join(d, x), dst_files)
         env.Command(dfiles, unpack_zip_files, [
-            "rm -rf %s" % os.path.join(unpack_zip_dir, pkg_version, 'build'),
-            "rm -rf $TEST_ZIP_DIR",
-            "$PYTHON %s install --prefix=$TEST_ZIP_DIR" % \
+            Delete(os.path.join(unpack_zip_dir, pkg_version, 'build')),
+            Delete("$TEST_ZIP_DIR"),
+            '$PYTHON "%s" install "--prefix=$TEST_ZIP_DIR"' % \
                 os.path.join(unpack_zip_dir, pkg_version, 'setup.py'),
         ])
 
 
 
     #
-    # Generate portage files for submission to Gentoo Linux.
-    #
-    gentoo = os.path.join('build', 'gentoo')
-    ebuild = os.path.join(gentoo, 'scons-%s.ebuild' % version)
-    digest = os.path.join(gentoo, 'files', 'digest-scons-%s' % version)
-    env.Command(ebuild, os.path.join('gentoo', 'scons.ebuild.in'), SCons_revision)
-    def Digestify(target, source, env):
-        import md5
-	def hexdigest(s):
-	    """Return a signature as a string of hex characters.
-	    """
-	    # NOTE:  This routine is a method in the Python 2.0 interface
-	    # of the native md5 module, but we want SCons to operate all
-	    # the way back to at least Python 1.5.2, which doesn't have it.
-	    h = string.hexdigits
-	    r = ''
-	    for c in s:
-	        i = ord(c)
-	        r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
-	    return r
-        src = source[0].rfile()
-        contents = open(str(src)).read()
-        sig = hexdigest(md5.new(contents).digest())
-        bytes = os.stat(str(src))[6]
-        open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig,
-                                                            src.name,
-                                                            bytes))
-    env.Command(digest, tar_gz, Digestify)
-
-    #
     # Use the Python distutils to generate the appropriate packages.
     #
     commands = [
-        "rm -rf %s" % os.path.join(build, 'build', 'lib'),
-        "rm -rf %s" % os.path.join(build, 'build', 'scripts'),
+        Delete(os.path.join(build, 'build', 'lib')),
+        Delete(os.path.join(build, 'build', 'scripts')),
     ]
 
     if distutils_formats:
-        commands.append("rm -rf %s" % os.path.join(build,
-                                                   'build',
-                                                   'bdist.' + platform,
-                                                   'dumb'))
+        commands.append(Delete(os.path.join(build,
+                                            'build',
+                                            'bdist.' + platform,
+                                            'dumb')))
         for format in distutils_formats:
             commands.append("$PYTHON $SETUP_PY bdist_dumb -f %s" % format)
 
     local_zip = os.path.join('build', 'dist', "%s.zip" % s_l_v)
 
     commands = [
-        "rm -rf %s" % local,
-        "$PYTHON $SETUP_PY install --install-script=%s --install-lib=%s --no-compile" % \
+        Delete(local),
+        '$PYTHON $SETUP_PY install "--install-script=%s" "--install-lib=%s" --no-compile' % \
                                                 (cwd_local, cwd_local_slv),
     ]
 
     for script in scripts:
-        commands.append("mv %s/%s %s/%s.py" % (local, script, local, script))
+        #commands.append("mv %s/%s %s/%s.py" % (local, script, local, script))
+        local_script = os.path.join(local, script)
+        commands.append(Move(local_script + '.py', local_script))
 
     rf = filter(lambda x: not x in scripts, raw_files)
     rf = map(lambda x, slv=s_l_v: os.path.join(slv, x), rf)
         unpack_targets = map(lambda x, d=test_local_tar_gz_dir:
                                     os.path.join(d, x),
                              rf)
-        commands = ["rm -rf %s" % test_local_tar_gz_dir,
-                    "mkdir %s" % test_local_tar_gz_dir,
+        commands = [Delete(test_local_tar_gz_dir),
+                    Mkdir(test_local_tar_gz_dir),
                     "cd %s && tar xzf $( ${SOURCE.abspath} $)" % test_local_tar_gz_dir]
 
         env.Command(unpack_targets, local_tar_gz, commands)
         unpack_targets = map(lambda x, d=test_local_zip_dir:
                                     os.path.join(d, x),
                              rf)
-        commands = ["rm -rf %s" % test_local_zip_dir,
-                    "mkdir %s" % test_local_zip_dir,
+        commands = [Delete(test_local_zip_dir),
+                    Mkdir(test_local_zip_dir),
                     unzipit]
 
         env.Command(unpack_targets, local_zip, unzipit,
 
         b_ps_files = map(lambda x, d=b_ps: os.path.join(d, x), sfiles)
         cmds = [
-            "rm -rf %s" % b_psv,
-            "cp -rp %s %s" % (b_ps, b_psv),
-            "find %s -name .sconsign -exec rm {} \\;" % b_psv,
-            "touch $TARGET",
+            Delete(b_psv),
+            Copy(b_psv, b_ps),
+            Touch("$TARGET"),
         ]
 
         env.Command(b_psv_stamp, src_deps + b_ps_files, cmds)
             #
             # We'd like to replace the last three lines with the following:
             #
-            #	tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
+            #   tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
             #
             # but that gives heartburn to Cygwin's tar, so work around it
             # with separate zcat-tar-rm commands.
             env.Command(unpack_tar_gz_files, src_tar_gz, [
-                "rm -rf %s" % os.path.join(unpack_tar_gz_dir, psv),
+                Delete(os.path.join(unpack_tar_gz_dir, psv)),
                 "$ZCAT $SOURCES > .temp",
                 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
-                "rm -f .temp",
+                Delete(".temp"),
             ])
 
             #
             ENV['USERNAME'] = developer
             env.Command(dfiles, unpack_tar_gz_files,
                 [
-                "rm -rf %s" % os.path.join(unpack_tar_gz_dir,
-                                           psv,
-                                           'build',
-                                           'scons',
-                                           'build'),
-                "rm -rf $TEST_SRC_TAR_GZ_DIR",
-                "cd %s && $PYTHON %s %s" % \
+                Delete(os.path.join(unpack_tar_gz_dir,
+                                    psv,
+                                    'build',
+                                    'scons',
+                                    'build')),
+                Delete("$TEST_SRC_TAR_GZ_DIR"),
+                'cd "%s" && $PYTHON "%s" "%s"' % \
                     (os.path.join(unpack_tar_gz_dir, psv),
                      os.path.join('src', 'script', 'scons.py'),
                      os.path.join('build', 'scons')),
-                "$PYTHON %s install --prefix=$TEST_SRC_TAR_GZ_DIR" % \
+                '$PYTHON "%s" install "--prefix=$TEST_SRC_TAR_GZ_DIR"' % \
                     os.path.join(unpack_tar_gz_dir,
                                  psv,
                                  'build',
                                       sfiles)
 
             env.Command(unpack_zip_files, src_zip, [
-                "rm -rf %s" % os.path.join(unpack_zip_dir, psv),
+                Delete(os.path.join(unpack_zip_dir, psv)),
                 unzipit
             ])
 
             ENV['USERNAME'] = developer
             env.Command(dfiles, unpack_zip_files,
                 [
-                "rm -rf %s" % os.path.join(unpack_zip_dir,
-                                           psv,
-                                           'build',
-                                           'scons',
-                                           'build'),
-                "rm -rf $TEST_SRC_ZIP_DIR",
-                "cd %s && $PYTHON %s %s" % \
+                Delete(os.path.join(unpack_zip_dir,
+                                    psv,
+                                    'build',
+                                    'scons',
+                                    'build')),
+                Delete("$TEST_SRC_ZIP_DIR"),
+                'cd "%s" && $PYTHON "%s" "%s"' % \
                     (os.path.join(unpack_zip_dir, psv),
                      os.path.join('src', 'script', 'scons.py'),
                      os.path.join('build', 'scons')),
-                "$PYTHON %s install --prefix=$TEST_SRC_ZIP_DIR" % \
+                '$PYTHON "%s" install "--prefix=$TEST_SRC_ZIP_DIR"' % \
                     os.path.join(unpack_zip_dir,
                                  psv,
                                  'build',

File doc/SConscript

 
         if docs[doc].get('html') and jade:
             cmds = [
-                "rm -f ${TARGET.dir}/*.html",
+                Delete("${TARGET.dir}/*.html"),
                 "jw -b html -o ${TARGET.dir} $SOURCES",
-                "mv -v ${TARGET.dir}/index.html $TARGET || true",
             ]
             if tidy:
                 cmds.append("tidy -m -q $TARGET || true")
             Local(htmlindex)
 
             cmds = [
-                "rm -f ${TARGET.dir}/main.html",
+                Delete("${TARGET.dir}/main.html"),
                 "jw -u -b html -o ${TARGET.dir} $SOURCES",
-                "mv -v ${TARGET.dir}/main.html $TARGET || true",
+                Move("$TARGET", "${TARGET.dir}/main.html"),
             ]
             if tidy:
                 cmds.append("tidy -m -q $TARGET || true")
 
         if docs[doc].get('ps') and jadetex:
             env.Command(ps, main, [
-                "rm -f ${TARGET.dir}/%s" % out,
+                Delete("${TARGET.dir}/%s" % out),
                 "jw -b ps -o ${TARGET.dir} $SOURCES",
                 "mv ${TARGET.dir}/main.ps $TARGET",
-                "rm -f ${TARGET.dir}/%s" % out,
+                Delete("${TARGET.dir}/%s" % out),
             ])
             Local(ps)
 
 
         if docs[doc].get('pdf') and pdfjadetex:
             env.Command(pdf, main, [
-                "rm -f ${TARGET.dir}/%s" % out,
+                Delete("${TARGET.dir}/%s" % out),
                 "jw -b pdf -o ${TARGET.dir} $SOURCES",
                 "mv ${TARGET.dir}/main.pdf $TARGET",
-                "rm -f ${TARGET.dir}/out",
+                Delete("${TARGET.dir}/out"),
             ])
             Local(pdf)
 

File src/CHANGES.txt

 
   - Make the scons.bat REM statements into @REM so they aren't printed.
 
+  - Make the SCons packaging SConscript files platform independent.
+
   From Anthony Roach:
 
   - Fix scanning of pre-compiled header (.pch) files for #includes,