2 # SConstruct file to build scons packages during development.
4 # See the README file for an overview of how SCons is built and tested.
8 # Copyright (c) 2001, 2002 Steven Knight
10 # Permission is hereby granted, free of charge, to any person obtaining
11 # a copy of this software and associated documentation files (the
12 # "Software"), to deal in the Software without restriction, including
13 # without limitation the rights to use, copy, modify, merge, publish,
14 # distribute, sublicense, and/or sell copies of the Software, and to
15 # permit persons to whom the Software is furnished to do so, subject to
16 # the following conditions:
18 # The above copyright notice and this permission notice shall be included
19 # in all copies or substantial portions of the Software.
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
22 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
23 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 default_version = '0.08'
45 # An internal "whereis" routine to figure out if a given program
46 # is available on this system.
49 for dir in string.split(os.environ['PATH'], os.pathsep):
50 f = os.path.join(dir, file)
56 if stat.S_IMODE(st[stat.ST_MODE]) & 0111:
61 # We let the presence or absence of various utilities determine
62 # whether or not we bother to build certain pieces of things.
63 # This should allow people to still do SCons work even if they
64 # don't have Aegis or RPM installed, for example.
66 aegis = whereis('aegis')
67 aesub = whereis('aesub')
68 dh_builddeb = whereis('dh_builddeb')
69 fakeroot = whereis('fakeroot')
70 gzip = whereis('gzip')
72 unzip = whereis('unzip')
76 # Now grab the information that we "build" into the files.
79 date = ARGUMENTS['date']
81 date = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(time.time()))
83 if ARGUMENTS.has_key('developer'):
84 developer = ARGUMENTS['developer']
85 elif os.environ.has_key('USERNAME'):
86 developer = os.environ['USERNAME']
87 elif os.environ.has_key('LOGNAME'):
88 developer = os.environ['LOGNAME']
89 elif os.environ.has_key('USER'):
90 developer = os.environ['USER']
92 if ARGUMENTS.has_key('build_system'):
93 build_system = ARGUMENTS['build_system']
95 build_system = string.split(socket.gethostname(), '.')[0]
97 if ARGUMENTS.has_key('version'):
98 revision = ARGUMENTS['version']
100 revision = os.popen(aesub + " \\$version", "r").read()[:-1]
102 revision = default_version
104 a = string.split(revision, '.')
110 revision = string.join(arr, '.')
112 # Here's how we'd turn the calculated $revision into our package $version.
113 # This makes it difficult to coordinate with other files (debian/changelog
114 # and rpm/scons.spec) that hard-code the version number, so just go with
115 # the flow for now and hard code it here, too.
119 # if str[0] == 'C' or str[0] == 'D':
121 # while len(str) > 2 and str[0] == '0':
124 #arr = map(lambda x, xxx=xxx: xxx(x), arr)
125 #version = string.join(arr, '.')
126 version = default_version
128 build_id = string.replace(revision, version + '.', '')
130 if ARGUMENTS.has_key('change'):
131 change = ARGUMENTS['change']
133 change = os.popen(aesub + " \\$change", "r").read()[:-1]
135 change = default_version
137 python_ver = sys.version[0:3]
139 platform = distutils.util.get_platform()
141 ENV = { 'PATH' : os.environ['PATH'] }
142 for key in ['AEGIS_PROJECT', 'PYTHONPATH']:
143 if os.environ.has_key(key):
144 ENV[key] = os.environ[key]
146 lib_project = os.path.join("lib", project)
148 cwd_build = os.path.join(os.getcwd(), "build")
150 test_deb_dir = os.path.join(cwd_build, "test-deb")
151 test_rpm_dir = os.path.join(cwd_build, "test-rpm")
152 test_tar_gz_dir = os.path.join(cwd_build, "test-tar-gz")
153 test_src_tar_gz_dir = os.path.join(cwd_build, "test-src-tar-gz")
154 test_zip_dir = os.path.join(cwd_build, "test-zip")
155 test_src_zip_dir = os.path.join(cwd_build, "test-src-zip")
157 unpack_tar_gz_dir = os.path.join(cwd_build, "unpack-tar-gz")
158 unpack_zip_dir = os.path.join(cwd_build, "unpack-zip")
160 if platform == "win32":
162 python_project_subinst_dir = None
163 project_script_subinst_dir = 'Scripts'
166 python_project_subinst_dir = lib_project
167 project_script_subinst_dir = 'bin'
173 # Figure out if we can handle .zip files.
178 def zipit(env, target, source):
179 print "Zipping %s:" % str(target[0])
180 def visit(arg, dirname, names):
182 path = os.path.join(dirname, name)
183 if os.path.isfile(path):
185 zf = zipfile.ZipFile(str(target[0]), 'w')
187 os.path.walk(env['PSV'], visit, zf)
191 def unzipit(env, target, source):
192 print "Unzipping %s:" % str(source[0])
193 zf = zipfile.ZipFile(str(source[0]), 'r')
194 for name in zf.namelist():
195 dest = os.path.join(env['UNPACK_ZIP_DIR'], name)
196 dir = os.path.dirname(dest)
202 # if the file exists, then delete it before writing
203 # to it so that we don't end up trying to write to a symlink:
204 if os.path.isfile(dest) or os.path.islink(dest):
206 if not os.path.isdir(dest):
207 open(dest, 'w').write(zf.read(name))
211 zipit = "cd build && $ZIP $ZIPFLAGS dist/${TARGET.file} $PSV"
212 unzipit = "$UNZIP $UNZIPFLAGS $SOURCES"
214 def SCons_revision(target, source, env):
215 """Interpolate specific values from the environment into a file.
217 This is used to copy files into a tree that gets packaged up
218 into the source file package.
222 # Note: We don't use $VERSION from the environment so that
223 # this routine will change when the version number changes
224 # and things will get rebuilt properly.
226 print "SCons_revision() < %s > %s" % (s, t)
229 for line in inf.readlines():
230 # Note: We construct the __*__ substitution strings here
231 # so that they don't get replaced when this file gets
232 # copied into the tree for packaging.
233 line = string.replace(line, '__BUILD' + '__', env['BUILD'])
234 line = string.replace(line, '__BUILDSYS' + '__', env['BUILDSYS'])
235 line = string.replace(line, '__DATE' + '__', env['DATE'])
236 line = string.replace(line, '__DEVELOPER' + '__', env['DEVELOPER'])
237 line = string.replace(line, '__FILE' + '__', s)
238 line = string.replace(line, '__REVISION' + '__', env['REVISION'])
239 line = string.replace(line, '__VERSION' + '__', version)
243 os.chmod(t, os.stat(s)[0])
245 revbuilder = Builder(action = SCons_revision)
251 BUILDSYS = build_system,
253 DEVELOPER = developer,
258 TAR_HFLAG = tar_hflag,
263 UNZIPFLAGS = '-o -d $UNPACK_ZIP_DIR',
267 TEST_DEB_DIR = test_deb_dir,
268 TEST_RPM_DIR = test_rpm_dir,
269 TEST_SRC_TAR_GZ_DIR = test_src_tar_gz_dir,
270 TEST_SRC_ZIP_DIR = test_src_zip_dir,
271 TEST_TAR_GZ_DIR = test_tar_gz_dir,
272 TEST_ZIP_DIR = test_zip_dir,
274 UNPACK_TAR_GZ_DIR = unpack_tar_gz_dir,
275 UNPACK_ZIP_DIR = unpack_zip_dir,
277 BUILDERS = { 'SCons_revision' : revbuilder },
279 PYTHON = sys.executable
283 # Define SCons packages.
285 # In the original, more complicated packaging scheme, we were going
286 # to have separate packages for:
288 # python-scons only the build engine
289 # scons-script only the script
290 # scons the script plus the build engine
292 # We're now only delivering a single "scons" package, but this is still
293 # "built" as two sub-packages (the build engine and the script), so
294 # the definitions remain here, even though we're not using them for
299 'pkg' : 'python-' + project,
300 'src_subdir' : 'engine',
301 'inst_subdir' : os.path.join('lib', 'python1.5', 'site-packages'),
314 'files' : [ 'LICENSE.txt',
321 'LICENSE.txt' : '../LICENSE.txt'
326 # The original packaging scheme would have have required us to push
327 # the Python version number into the package name (python1.5-scons,
328 # python2.0-scons, etc.), which would have required a definition
329 # like the following. Leave this here in case we ever decide to do
330 # this in the future, but note that this would require some modification
331 # to src/engine/setup.py before it would really work.
334 # 'pkg' : 'python2-' + project,
335 # 'src_subdir' : 'engine',
336 # 'inst_subdir' : os.path.join('lib', 'python2.1', 'site-packages'),
339 # 'debian/changelog',
341 # 'debian/copyright',
356 # 'LICENSE.txt' : '../LICENSE.txt',
362 'pkg' : project + '-script',
363 'src_subdir' : 'script',
364 'inst_subdir' : 'bin',
385 'LICENSE.txt' : '../LICENSE.txt',
386 'scons' : 'scons.py',
409 'os_spawnv_fix.diff',
417 'scons.1' : '../doc/man/scons.1',
420 'subpkgs' : [ python_scons, scons_script ],
423 'python-' + project : python_project_subinst_dir,
424 project + '-script' : project_script_subinst_dir,
433 # Initialize variables with the right directories for this package.
436 pkg_version = "%s-%s" % (pkg, version)
439 if p.has_key('src_subdir'):
440 src = os.path.join(src, p['src_subdir'])
442 build = os.path.join('build', pkg)
444 tar_gz = os.path.join(build, 'dist', "%s.tar.gz" % pkg_version)
445 platform_tar_gz = os.path.join(build,
447 "%s.%s.tar.gz" % (pkg_version, platform))
448 zip = os.path.join(build, 'dist', "%s.zip" % pkg_version)
449 platform_zip = os.path.join(build,
451 "%s.%s.zip" % (pkg_version, platform))
452 win32_exe = os.path.join(build, 'dist', "%s.win32.exe" % pkg_version)
455 # Update the environment with the relevant information
458 # We can get away with calling setup.py using a directory path
459 # like this because we put a preamble in it that will chdir()
460 # to the directory in which setup.py exists.
462 env.Update(PKG = pkg,
463 PKG_VERSION = pkg_version,
464 SETUP_PY = os.path.join(build, 'setup.py'))
467 # Read up the list of source files from our MANIFEST.in.
468 # This list should *not* include LICENSE.txt, MANIFEST,
469 # README.txt, or setup.py. Make a copy of the list for the
472 src_files = map(lambda x: x[:-1],
473 open(os.path.join(src, 'MANIFEST.in')).readlines())
474 dst_files = src_files[:]
476 MANIFEST_in_list = []
478 if p.has_key('subpkgs'):
480 # This package includes some sub-packages. Read up their
481 # MANIFEST.in files, and add them to our source and destination
482 # file lists, modifying them as appropriate to add the
485 for sp in p['subpkgs']:
486 ssubdir = sp['src_subdir']
487 isubdir = p['subinst_dirs'][sp['pkg']]
488 MANIFEST_in = os.path.join(src, ssubdir, 'MANIFEST.in')
489 MANIFEST_in_list.append(MANIFEST_in)
490 f = map(lambda x: x[:-1], open(MANIFEST_in).readlines())
491 src_files.extend(map(lambda x, s=ssubdir: os.path.join(s, x), f))
493 f = map(lambda x, i=isubdir: os.path.join(i, x), f)
495 for k in sp['filemap'].keys():
498 k = os.path.join(sp['src_subdir'], k)
499 p['filemap'][k] = os.path.join(sp['src_subdir'], f)
502 # Now that we have the "normal" source files, add those files
503 # that are standard for each distribution. Note that we don't
504 # add these to dst_files, because they don't get installed.
505 # And we still have the MANIFEST to add.
507 src_files.extend(p['files'])
510 # Now run everything in src_file through the sed command we
511 # concocted to expand __FILE__, __VERSION__, etc.
514 s = p['filemap'].get(b, b)
515 env.SCons_revision(os.path.join(build, b), os.path.join(src, s))
518 # NOW, finally, we can create the MANIFEST, which we do
519 # by having Python spit out the contents of the src_files
520 # array we've carefully created. After we've added
521 # MANIFEST itself to the array, of course.
523 src_files.append("MANIFEST")
524 MANIFEST_in_list.append(os.path.join(src, 'MANIFEST.in'))
526 def copy(target, source, **kw):
529 f = open(str(target[0]), 'wb')
530 for file in src_files:
534 env.Command(os.path.join(build, 'MANIFEST'), MANIFEST_in_list, copy)
537 # Now go through and arrange to create whatever packages we can.
539 build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files)
541 distutils_formats = []
543 distutils_targets = [ win32_exe ]
545 install_targets = distutils_targets[:]
549 distutils_formats.append('gztar')
551 src_deps.append(tar_gz)
553 distutils_targets.extend([ tar_gz, platform_tar_gz ])
554 install_targets.extend([ tar_gz, platform_tar_gz ])
557 # Unpack the tar.gz archive created by the distutils into
558 # build/unpack-tar-gz/scons-{version}.
560 # We'd like to replace the last three lines with the following:
562 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
564 # but that gives heartburn to Cygwin's tar, so work around it
565 # with separate zcat-tar-rm commands.
567 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, pv=pkg_version:
568 os.path.join(u, pv, x),
570 env.Command(unpack_tar_gz_files, tar_gz, [
571 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version),
572 "$ZCAT $SOURCES > .temp",
573 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
578 # Run setup.py in the unpacked subdirectory to "install" everything
579 # into our build/test subdirectory. The runtest.py script will set
580 # PYTHONPATH so that the tests only look under build/test-{package},
581 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
582 # and unittest.py). This makes sure that our tests pass with what
583 # we really packaged, not because of something hanging around in
584 # the development directory.
586 # We can get away with calling setup.py using a directory path
587 # like this because we put a preamble in it that will chdir()
588 # to the directory in which setup.py exists.
590 dfiles = map(lambda x, d=test_tar_gz_dir: os.path.join(d, x), dst_files)
591 env.Command(dfiles, unpack_tar_gz_files, [
592 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, pkg_version, 'build'),
593 "rm -rf $TEST_TAR_GZ_DIR",
594 "$PYTHON %s install --prefix=$TEST_TAR_GZ_DIR" % \
595 os.path.join(unpack_tar_gz_dir, pkg_version, 'setup.py'),
600 distutils_formats.append('zip')
604 distutils_targets.extend([ zip, platform_zip ])
605 install_targets.extend([ zip, platform_zip ])
608 # Unpack the zip archive created by the distutils into
609 # build/unpack-zip/scons-{version}.
611 unpack_zip_files = map(lambda x, u=unpack_zip_dir, pv=pkg_version:
612 os.path.join(u, pv, x),
615 env.Command(unpack_zip_files, zip, unzipit)
618 # Run setup.py in the unpacked subdirectory to "install" everything
619 # into our build/test subdirectory. The runtest.py script will set
620 # PYTHONPATH so that the tests only look under build/test-{package},
621 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
622 # and unittest.py). This makes sure that our tests pass with what
623 # we really packaged, not because of something hanging around in
624 # the development directory.
626 # We can get away with calling setup.py using a directory path
627 # like this because we put a preamble in it that will chdir()
628 # to the directory in which setup.py exists.
630 dfiles = map(lambda x, d=test_zip_dir: os.path.join(d, x), dst_files)
631 env.Command(dfiles, unpack_zip_files, [
632 "rm -rf %s" % os.path.join(unpack_zip_dir, pkg_version, 'build'),
633 "rm -rf $TEST_ZIP_DIR",
634 "$PYTHON %s install --prefix=$TEST_ZIP_DIR" % \
635 os.path.join(unpack_zip_dir, pkg_version, 'setup.py'),
639 topdir = os.path.join(os.getcwd(), build, 'build',
640 'bdist.' + platform, 'rpm')
642 BUILDdir = os.path.join(topdir, 'BUILD', pkg + '-' + version)
643 RPMSdir = os.path.join(topdir, 'RPMS', 'noarch')
644 SOURCESdir = os.path.join(topdir, 'SOURCES')
645 SPECSdir = os.path.join(topdir, 'SPECS')
646 SRPMSdir = os.path.join(topdir, 'SRPMS')
648 specfile = os.path.join(SPECSdir, "%s-1.spec" % pkg_version)
649 sourcefile = os.path.join(SOURCESdir, "%s.tar.gz" % pkg_version);
650 rpm = os.path.join(RPMSdir, "%s-1.noarch.rpm" % pkg_version)
651 src_rpm = os.path.join(SRPMSdir, "%s-1.src.rpm" % pkg_version)
653 env.InstallAs(specfile, os.path.join('rpm', "%s.spec" % pkg))
654 env.InstallAs(sourcefile, tar_gz)
656 targets = [ rpm, src_rpm ]
657 cmd = "rpm --define '_topdir $(%s$)' -ba $SOURCES" % topdir
658 if not os.path.isdir(BUILDdir):
659 cmd = ("$( mkdir -p %s; $)" % BUILDdir) + cmd
660 env.Command(targets, specfile, cmd)
661 env.Depends(targets, sourcefile)
663 install_targets.extend(targets)
665 dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x),
669 "rpm2cpio $SOURCES | (cd $TEST_RPM_DIR && cpio -id)")
671 if dh_builddeb and fakeroot:
672 # Our Debian packaging builds directly into build/dist,
673 # so we don't need to add the .debs to install_targets.
674 deb = os.path.join('build', 'dist', "%s_%s-1_all.deb" % (pkg, version))
675 for d in p['debian_deps']:
676 b = env.SCons_revision(os.path.join(build, d), d)
678 env.Command(deb, build_src_files, [
679 "cd %s && fakeroot make -f debian/rules PYTHON=$PYTHON BUILDDEB_OPTIONS=--destdir=../../build/dist binary" % build,
682 old = os.path.join('lib', 'scons', '')
683 new = os.path.join('lib', 'python2.1', 'site-packages', '')
684 def xxx(s, old=old, new=new):
685 if s[:len(old)] == old:
686 s = new + s[len(old):]
687 return os.path.join('usr', s)
688 dfiles = map(lambda x, t=test_deb_dir: os.path.join(t, x),
692 "dpkg --fsys-tarfile $SOURCES | (cd $TEST_DEB_DIR && tar -xf -)")
695 # Use the Python distutils to generate the appropriate packages.
698 "rm -rf %s" % os.path.join(build, 'build', 'lib'),
699 "rm -rf %s" % os.path.join(build, 'build', 'scripts'),
702 if distutils_formats:
703 commands.append("rm -rf %s" % os.path.join(build,
707 for format in distutils_formats:
708 commands.append("$PYTHON $SETUP_PY bdist_dumb -f %s" % format)
710 commands.append("$PYTHON $SETUP_PY sdist --formats=%s" % \
711 string.join(distutils_formats, ','))
713 commands.append("$PYTHON $SETUP_PY bdist_wininst")
715 env.Command(distutils_targets, build_src_files, commands)
718 # And, lastly, install the appropriate packages in the
719 # appropriate subdirectory.
721 env.Install(os.path.join('build', 'dist'), install_targets)
728 SConscript('etc/SConscript')
733 BuildDir('build/doc', 'doc')
735 Export('env', 'whereis')
737 SConscript('build/doc/SConscript')
740 # If we're running in the actual Aegis project, pack up a complete
741 # source archive from the project files and files in the change,
742 # so we can share it with helpful developers who don't use Aegis.
747 cmd = "aegis -list -unf -c %s cf 2>/dev/null" % change
748 for line in map(lambda x: x[:-1], os.popen(cmd, "r").readlines()):
749 a = string.split(line)
753 cmd = "aegis -list -terse pf 2>/dev/null"
754 pf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
755 cmd = "aegis -list -terse cf 2>/dev/null"
756 cf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines())
762 sfiles = filter(lambda x: x[-9:] != '.aeignore' and x[-9:] != '.sconsign',
766 ps = "%s-src" % project
767 psv = "%s-%s" % (ps, version)
768 b_ps = os.path.join('build', ps)
769 b_psv = os.path.join('build', psv)
770 b_psv_stamp = b_psv + '-stamp'
772 src_tar_gz = os.path.join('build', 'dist', '%s.tar.gz' % psv)
773 src_zip = os.path.join('build', 'dist', '%s.zip' % psv)
776 env.SCons_revision(os.path.join(b_ps, file), file)
778 b_ps_files = map(lambda x, d=b_ps: os.path.join(d, x), sfiles)
781 "cp -rp %s %s" % (b_ps, b_psv),
782 "find %s -name .sconsign -exec rm {} \\;" % b_psv,
786 env.Command(b_psv_stamp, src_deps + b_ps_files, cmds)
790 env.Command(src_tar_gz, b_psv_stamp,
791 "tar cz${TAR_HFLAG} -f $TARGET -C build %s" % psv)
794 # Unpack the archive into build/unpack/scons-{version}.
796 unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, psv=psv:
797 os.path.join(u, psv, x),
801 # We'd like to replace the last three lines with the following:
803 # tar zxf $SOURCES -C $UNPACK_TAR_GZ_DIR
805 # but that gives heartburn to Cygwin's tar, so work around it
806 # with separate zcat-tar-rm commands.
807 env.Command(unpack_tar_gz_files, src_tar_gz, [
808 "rm -rf %s" % os.path.join(unpack_tar_gz_dir, psv),
809 "$ZCAT $SOURCES > .temp",
810 "tar xf .temp -C $UNPACK_TAR_GZ_DIR",
815 # Run setup.py in the unpacked subdirectory to "install" everything
816 # into our build/test subdirectory. The runtest.py script will set
817 # PYTHONPATH so that the tests only look under build/test-{package},
818 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
819 # and unittest.py). This makes sure that our tests pass with what
820 # we really packaged, not because of something hanging around in
821 # the development directory.
823 # We can get away with calling setup.py using a directory path
824 # like this because we put a preamble in it that will chdir()
825 # to the directory in which setup.py exists.
827 dfiles = map(lambda x, d=test_src_tar_gz_dir: os.path.join(d, x),
829 ENV = env.Dictionary('ENV')
830 ENV['SCONS_LIB_DIR'] = os.path.join(unpack_tar_gz_dir, psv, 'src', 'engine')
831 ENV['USERNAME'] = developer
832 env.Copy(ENV = ENV).Command(dfiles, unpack_tar_gz_files, [
833 "rm -rf %s" % os.path.join(unpack_tar_gz_dir,
838 "rm -rf $TEST_SRC_TAR_GZ_DIR",
839 "cd %s && $PYTHON %s %s" % \
840 (os.path.join(unpack_tar_gz_dir, psv),
841 os.path.join('src', 'script', 'scons.py'),
842 os.path.join('build', 'scons')),
843 "$PYTHON %s install --prefix=$TEST_SRC_TAR_GZ_DIR" % \
844 os.path.join(unpack_tar_gz_dir,
853 env.Copy(PSV = psv).Command(src_zip, b_psv_stamp, zipit)
856 # Unpack the archive into build/unpack/scons-{version}.
858 unpack_zip_files = map(lambda x, u=unpack_zip_dir, psv=psv:
859 os.path.join(u, psv, x),
862 env.Command(unpack_zip_files, src_zip, unzipit)
865 # Run setup.py in the unpacked subdirectory to "install" everything
866 # into our build/test subdirectory. The runtest.py script will set
867 # PYTHONPATH so that the tests only look under build/test-{package},
868 # and under etc (for the testing modules TestCmd.py, TestSCons.py,
869 # and unittest.py). This makes sure that our tests pass with what
870 # we really packaged, not because of something hanging around in
871 # the development directory.
873 # We can get away with calling setup.py using a directory path
874 # like this because we put a preamble in it that will chdir()
875 # to the directory in which setup.py exists.
877 dfiles = map(lambda x, d=test_src_zip_dir: os.path.join(d, x),
879 ENV = env.Dictionary('ENV')
880 ENV['SCONS_LIB_DIR'] = os.path.join(unpack_zip_dir, psv, 'src', 'engine')
881 ENV['USERNAME'] = developer
882 env.Copy(ENV = ENV).Command(dfiles, unpack_zip_files, [
883 "rm -rf %s" % os.path.join(unpack_zip_dir,
888 "rm -rf $TEST_SRC_ZIP_DIR",
889 "cd %s && $PYTHON %s %s" % \
890 (os.path.join(unpack_zip_dir, psv),
891 os.path.join('src', 'script', 'scons.py'),
892 os.path.join('build', 'scons')),
893 "$PYTHON %s install --prefix=$TEST_SRC_ZIP_DIR" % \
894 os.path.join(unpack_zip_dir,