From baee03c569c91b745a1e025660b19a718db16e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Thu, 28 Sep 2017 12:18:58 +0200 Subject: New upstream version 3.0.0 --- SConstruct | 208 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 113 insertions(+), 95 deletions(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index 16d01d2..68f9e3f 100644 --- a/SConstruct +++ b/SConstruct @@ -3,13 +3,15 @@ # # See the README.rst file for an overview of how SCons is built and tested. -copyright_years = '2001 - 2016' +from __future__ import print_function + +copyright_years = '2001 - 2017' # This gets inserted into the man pages to reflect the month of release. -month_year = 'November 2016' +month_year = 'September 2017' # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -39,11 +41,12 @@ import re import stat import sys import tempfile +import time import bootstrap project = 'scons' -default_version = '2.5.1' +default_version = '3.0.0' copyright = "Copyright (c) %s The SCons Foundation" % copyright_years platform = distutils.util.get_platform() @@ -53,7 +56,7 @@ def is_windows(): return True else: return False - + SConsignFile() # @@ -73,7 +76,7 @@ def whereis(file): st = os.stat(f_ext) except: continue - if stat.S_IMODE(st[stat.ST_MODE]) & 0111: + if stat.S_IMODE(st[stat.ST_MODE]) & 0o111: return f_ext return None @@ -96,9 +99,13 @@ zip = whereis('zip') # date = ARGUMENTS.get('DATE') if not date: - import time date = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(time.time())) +# Datestring for debian +# Should look like: Mon, 03 Nov 2016 13:37:42 -0700 +deb_date = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) + + developer = ARGUMENTS.get('DEVELOPER') if not developer: for variable in ['USERNAME', 'LOGNAME', 'USER']: @@ -160,8 +167,17 @@ import distutils.command no_winpack_templates = not os.path.exists(os.path.join(os.path.split(distutils.command.__file__)[0],'wininst-9.0.exe')) skip_win_packages = ARGUMENTS.get('SKIP_WIN_PACKAGES',False) or no_winpack_templates + +if sys.version_info[0] > 2: + # TODO: Resolve this issue. Currently fails when run on windows with + # File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/bdist_wininst.py", line 262, in create_exe + # cfgdata = cfgdata.encode("mbcs") + # LookupError: unknown encoding: mbcs + print("Temporary PY3: Skipping windows package builds") + skip_win_packages = True + if skip_win_packages: - print "Skipping the build of Windows packages..." + print("Skipping the build of Windows packages...") python_ver = sys.version[0:3] @@ -324,22 +340,25 @@ try: import zipfile def zipit(env, target, source): - print "Zipping %s:" % str(target[0]) - def visit(arg, dirname, names): - for name in names: - path = os.path.join(dirname, name) + print("Zipping %s:" % str(target[0])) + def visit(arg, dirname, filenames): + for filename in filenames: + path = os.path.join(dirname, filename) if os.path.isfile(path): arg.write(path) # default ZipFile compression is ZIP_STORED zf = zipfile.ZipFile(str(target[0]), 'w', compression=zipfile.ZIP_DEFLATED) olddir = os.getcwd() os.chdir(env['CD']) - try: os.path.walk(env['PSV'], visit, zf) - finally: os.chdir(olddir) + try: + for dirname, dirnames, filenames in os.walk(env['PSV']): + visit(zf, dirname, filenames) + finally: + os.chdir(olddir) zf.close() def unzipit(env, target, source): - print "Unzipping %s:" % str(source[0]) + print("Unzipping %s:" % str(source[0])) zf = zipfile.ZipFile(str(source[0]), 'r') for name in zf.namelist(): dest = os.path.join(env['UNPACK_ZIP_DIR'], name) @@ -348,19 +367,21 @@ try: os.makedirs(dir) except: pass - print dest,name + print(dest,name) # if the file exists, then delete it before writing # to it so that we don't end up trying to write to a symlink: if os.path.isfile(dest) or os.path.islink(dest): os.unlink(dest) if not os.path.isdir(dest): - open(dest, 'wb').write(zf.read(name)) + with open(dest, 'wb') as fp: + fp.write(zf.read(name)) except ImportError: if unzip and zip: zipit = "cd $CD && $ZIP $ZIPFLAGS $( ${TARGET.abspath} $) $PSV" unzipit = "$UNZIP $UNZIPFLAGS $SOURCES" + def SCons_revision(target, source, env): """Interpolate specific values from the environment into a file. @@ -369,23 +390,38 @@ def SCons_revision(target, source, env): """ t = str(target[0]) s = source[0].rstr() - contents = open(s, 'rb').read() - # Note: We construct the __*__ substitution strings here - # so that they don't get replaced when this file gets - # copied into the tree for packaging. - contents = contents.replace('__BUILD' + '__', env['BUILD']) - contents = contents.replace('__BUILDSYS' + '__', env['BUILDSYS']) - contents = contents.replace('__COPYRIGHT' + '__', env['COPYRIGHT']) - contents = contents.replace('__DATE' + '__', env['DATE']) - contents = contents.replace('__DEVELOPER' + '__', env['DEVELOPER']) - contents = contents.replace('__FILE' + '__', str(source[0]).replace('\\', '/')) - contents = contents.replace('__MONTH_YEAR'+ '__', env['MONTH_YEAR']) - contents = contents.replace('__REVISION' + '__', env['REVISION']) - contents = contents.replace('__VERSION' + '__', env['VERSION']) - contents = contents.replace('__NULL' + '__', '') - open(t, 'wb').write(contents) + + try: + with open(s, 'r') as fp: + contents = fp.read() + + + # Note: We construct the __*__ substitution strings here + # so that they don't get replaced when this file gets + # copied into the tree for packaging. + contents = contents.replace('__BUILD' + '__', env['BUILD']) + contents = contents.replace('__BUILDSYS' + '__', env['BUILDSYS']) + contents = contents.replace('__COPYRIGHT' + '__', env['COPYRIGHT']) + contents = contents.replace('__DATE' + '__', env['DATE']) + contents = contents.replace('__DEB_DATE' + '__', env['DEB_DATE']) + + contents = contents.replace('__DEVELOPER' + '__', env['DEVELOPER']) + contents = contents.replace('__FILE' + '__', str(source[0]).replace('\\', '/')) + contents = contents.replace('__MONTH_YEAR'+ '__', env['MONTH_YEAR']) + contents = contents.replace('__REVISION' + '__', env['REVISION']) + contents = contents.replace('__VERSION' + '__', env['VERSION']) + contents = contents.replace('__NULL' + '__', '') + open(t, 'w').write(contents) + except UnicodeDecodeError as e: + print("Error decoding file:%s just copying no revision edit") + with open(s, 'rb') as fp: + contents = fp.read() + open(t, 'wb').write(contents) + + os.chmod(t, os.stat(s)[0]) + revaction = SCons_revision revbuilder = Builder(action = Action(SCons_revision, varlist=['COPYRIGHT', 'VERSION'])) @@ -434,12 +470,12 @@ env = Environment( BUILDSYS = build_system, COPYRIGHT = copyright, DATE = date, + DEB_DATE = deb_date, DEVELOPER = developer, DISTDIR = os.path.join(build_dir, 'dist'), MONTH_YEAR = month_year, REVISION = revision, VERSION = version, - DH_COMPAT = 2, TAR_HFLAG = tar_hflag, @@ -499,7 +535,8 @@ python_scons = { 'debian_deps' : [ 'debian/changelog', - 'debian/control', + 'debian/compat', + 'debian/control', 'debian/copyright', 'debian/dirs', 'debian/docs', @@ -559,7 +596,7 @@ else: i = install_egg_info(dist) i.finalize_options() import os.path - print os.path.split(i.outputs[0])[1] + print(os.path.split(i.outputs[0])[1]) """ % version try: @@ -576,43 +613,6 @@ finally: except EnvironmentError: pass -# -# The original packaging scheme would have have required us to push -# the Python version number into the package name (python1.5-scons, -# python2.0-scons, etc.), which would have required a definition -# like the following. Leave this here in case we ever decide to do -# this in the future, but note that this would require some modification -# to src/engine/setup.py before it would really work. -# -#python2_scons = { -# 'pkg' : 'python2-' + project, -# 'src_subdir' : 'engine', -# 'inst_subdir' : os.path.join('lib', 'python2.2', 'site-packages'), -# -# 'debian_deps' : [ -# 'debian/changelog', -# 'debian/control', -# 'debian/copyright', -# 'debian/dirs', -# 'debian/docs', -# 'debian/postinst', -# 'debian/prerm', -# 'debian/rules', -# ], -# -# 'files' : [ -# 'LICENSE.txt', -# 'README.txt', -# 'setup.cfg', -# 'setup.py', -# ], -# 'filemap' : { -# 'LICENSE.txt' : '../LICENSE.txt', -# }, -# 'buildermap' : {}, -#} -# - scons_script = { 'pkg' : project + '-script', 'src_subdir' : 'script', @@ -621,6 +621,7 @@ scons_script = { 'debian_deps' : [ 'debian/changelog', + 'debian/compat', 'debian/control', 'debian/copyright', 'debian/dirs', @@ -665,6 +666,7 @@ scons = { 'debian_deps' : [ 'debian/changelog', + 'debian/compat', 'debian/control', 'debian/copyright', 'debian/dirs', @@ -734,7 +736,7 @@ for p in [ scons ]: platform_zip = os.path.join(build, 'dist', "%s.%s.zip" % (pkg_version, platform)) - + # # Update the environment with the relevant information @@ -774,11 +776,16 @@ for p in [ scons ]: for sp in p['subpkgs']: ssubdir = sp['src_subdir'] isubdir = p['subinst_dirs'][sp['pkg']] + + MANIFEST_in = File(os.path.join(src, ssubdir, 'MANIFEST.in')).rstr() MANIFEST_in_list.append(MANIFEST_in) files = bootstrap.parseManifestLines(os.path.join(src, ssubdir), open(MANIFEST_in).readlines()) + raw_files.extend(files) src_files.extend([os.path.join(ssubdir, x) for x in files]) + + for f in files: r = os.path.join(sp['rpm_dir'], f) rpm_files.append(r) @@ -807,14 +814,16 @@ for p in [ scons ]: # # Now run everything in src_file through the sed command we - # concocted to expand SConstruct, 2.5.1, etc. + # concocted to expand SConstruct, 3.0.0, etc. # for b in src_files: s = p['filemap'].get(b, b) if not s[0] == '$' and not os.path.isabs(s): s = os.path.join(src, s) + builder = p['buildermap'].get(b, env.SCons_revision) x = builder(os.path.join(build, b), s) + Local(x) # @@ -829,7 +838,7 @@ for p in [ scons ]: def write_src_files(target, source, **kw): global src_files src_files.sort() - f = open(str(target[0]), 'wb') + f = open(str(target[0]), 'w') for file in src_files: f.write(file + "\n") f.close() @@ -856,11 +865,11 @@ for p in [ scons ]: for target in distutils_targets: dist_target = env.Install('$DISTDIR', target) - AddPostAction(dist_target, Chmod(dist_target, 0644)) + AddPostAction(dist_target, Chmod(dist_target, 0o644)) dist_distutils_targets += dist_target if not gzip: - print "gzip not found in %s; skipping .tar.gz package for %s." % (os.environ['PATH'], pkg) + print("gzip not found in %s; skipping .tar.gz package for %s." % (os.environ['PATH'], pkg)) else: distutils_formats.append('gztar') @@ -872,8 +881,8 @@ for p in [ scons ]: dist_tar_gz = env.Install('$DISTDIR', tar_gz) dist_platform_tar_gz = env.Install('$DISTDIR', platform_tar_gz) Local(dist_tar_gz, dist_platform_tar_gz) - AddPostAction(dist_tar_gz, Chmod(dist_tar_gz, 0644)) - AddPostAction(dist_platform_tar_gz, Chmod(dist_platform_tar_gz, 0644)) + AddPostAction(dist_tar_gz, Chmod(dist_tar_gz, 0o644)) + AddPostAction(dist_platform_tar_gz, Chmod(dist_platform_tar_gz, 0o644)) # # Unpack the tar.gz archive created by the distutils into @@ -923,11 +932,14 @@ for p in [ scons ]: 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 + import hashlib src = source[0].rfile() - contents = open(str(src)).read() - sig = md5.new(contents).hexdigest() + contents = open(str(src),'rb').read() + m = hashlib.md5() + m.update(contents) + sig = m.hexdigest() bytes = os.stat(str(src))[6] open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig, src.name, @@ -935,7 +947,7 @@ for p in [ scons ]: env.Command(digest, tar_gz, Digestify) if not zipit: - print "zip not found; skipping .zip package for %s." % pkg + print("zip not found; skipping .zip package for %s." % pkg) else: distutils_formats.append('zip') @@ -947,8 +959,8 @@ for p in [ scons ]: dist_zip = env.Install('$DISTDIR', zip) dist_platform_zip = env.Install('$DISTDIR', platform_zip) Local(dist_zip, dist_platform_zip) - AddPostAction(dist_zip, Chmod(dist_zip, 0644)) - AddPostAction(dist_platform_zip, Chmod(dist_platform_zip, 0644)) + AddPostAction(dist_zip, Chmod(dist_zip, 0o644)) + AddPostAction(dist_platform_zip, Chmod(dist_platform_zip, 0o644)) # # Unpack the zip archive created by the distutils into @@ -1011,10 +1023,10 @@ for p in [ scons ]: list generated from our MANIFEST(s), so we don't have to maintain multiple lists. """ - c = open(str(source[0]), 'rb').read() + c = open(str(source[0]), 'r').read() c = c.replace('__VERSION' + '__', env['VERSION']) c = c.replace('__RPM_FILES' + '__', env['RPM_FILES']) - open(str(target[0]), 'wb').write(c) + open(str(target[0]), 'w').write(c) rpm_files.sort() rpm_files_str = "\n".join(rpm_files) + "\n" @@ -1035,8 +1047,8 @@ for p in [ scons ]: dist_noarch_rpm = env.Install('$DISTDIR', noarch_rpm) dist_src_rpm = env.Install('$DISTDIR', src_rpm) Local(dist_noarch_rpm, dist_src_rpm) - AddPostAction(dist_noarch_rpm, Chmod(dist_noarch_rpm, 0644)) - AddPostAction(dist_src_rpm, Chmod(dist_src_rpm, 0644)) + AddPostAction(dist_noarch_rpm, Chmod(dist_noarch_rpm, 0o644)) + AddPostAction(dist_src_rpm, Chmod(dist_src_rpm, 0o644)) dfiles = [os.path.join(test_rpm_dir, 'usr', x) for x in dst_files] env.Command(dfiles, @@ -1047,9 +1059,9 @@ for p in [ scons ]: # Our Debian packaging builds directly into build/dist, # so we don't need to Install() the .debs. # The built deb is called just x.y.z, not x.y.z.final.0 so strip those off: - deb_version = '.'.join(version.split('.')[0:3]) + deb_version = version #'.'.join(version.split('.')[0:3]) deb = os.path.join(build_dir, 'dist', "%s_%s_all.deb" % (pkg, deb_version)) - # print "Building deb into %s (version=%s)"%(deb, deb_version) + print("Building deb into %s (version=%s)"%(deb, deb_version)) for d in p['debian_deps']: b = env.SCons_revision(os.path.join(build, d), d) env.Depends(deb, b) @@ -1109,8 +1121,8 @@ for p in [ scons ]: dist_local_tar_gz = os.path.join("$DISTDIR/%s.tar.gz" % s_l_v) dist_local_zip = os.path.join("$DISTDIR/%s.zip" % s_l_v) - AddPostAction(dist_local_tar_gz, Chmod(dist_local_tar_gz, 0644)) - AddPostAction(dist_local_zip, Chmod(dist_local_zip, 0644)) + AddPostAction(dist_local_tar_gz, Chmod(dist_local_tar_gz, 0o644)) + AddPostAction(dist_local_zip, Chmod(dist_local_zip, 0o644)) commands = [ Delete(build_dir_local), @@ -1220,7 +1232,7 @@ if hg_status_lines: slines = [l for l in hg_status_lines if l[0] in 'ACM'] sfiles = [l.split()[-1] for l in slines] else: - print "Not building in a Mercurial tree; skipping building src package." + print("Not building in a Mercurial tree; skipping building src package.") if sfiles: remove_patterns = [ @@ -1247,7 +1259,11 @@ if sfiles: Local(src_tar_gz, src_zip) for file in sfiles: - env.SCons_revision(os.path.join(b_ps, file), file) + if file.endswith('jpg') or file.endswith('png'): + # don't revision binary files. + env.Install(os.path.dirname(os.path.join(b_ps,file)), file) + else: + env.SCons_revision(os.path.join(b_ps, file), file) b_ps_files = [os.path.join(b_ps, x) for x in sfiles] cmds = [ @@ -1384,3 +1400,5 @@ for pf, help_text in packaging_flavors: os.path.join(build_dir, 'QMTest'), os.path.join(build_dir, 'runtest.py'), ]) + + -- cgit v1.2.3