From d84ade13bbbcbac87d811cdb616b4ca4c4f7a6d3 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 29 Feb 2016 21:31:18 -0800 Subject: [PATCH] Add --release_build CLI option. It turns off some dev-only options, and controls where uploads will go. --- build.py | 74 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/build.py b/build.py index 23dee9b4..c9effa64 100755 --- a/build.py +++ b/build.py @@ -147,9 +147,6 @@ def main(args): os.environ['PYTHONPATH'] = phoenixDir() os.environ['PYTHONUNBUFFERED'] = 'yes' os.environ['WXWIN'] = wxDir() - cfg = Config(noWxConfig=True) - msg('cfg.VERSION: %s' % cfg.VERSION) - msg('') wxpydir = os.path.join(phoenixDir(), "wx") if not os.path.exists(wxpydir): @@ -161,6 +158,10 @@ def main(args): options, commands = parseArgs(args) + cfg = Config(noWxConfig=True) + msg('cfg.VERSION: %s' % cfg.VERSION) + msg('') + while commands: # ensure that each command starts with the CWD being the phoenix dir. os.chdir(phoenixDir()) @@ -408,6 +409,7 @@ def makeOptionParser(): ("x64", (False, "Use and build for the 64bit version of Python on Windows")), ("jom", (False, "Use jom instead of nmake for the wxMSW build")), ("relwithdebug", (False, "Turn on the generation of debug info for release builds on MSW.")), + ("release_build", (False, "Turn off some development options for a release build.")), ] parser = optparse.OptionParser("build options:") @@ -418,19 +420,29 @@ def makeOptionParser(): action = 'store_true' parser.add_option('--'+opt, default=default, action=action, dest=opt, help=txt) - return parser def parseArgs(args): parser = makeOptionParser() options, args = parser.parse_args(args) + if isWindows: # We always use magic on Windows options.no_magic = False options.use_syswx = False elif options.use_syswx: + # Turn off magic if using the system wx options.no_magic = True + + # Some options don't make sense for release builds + if options.release_build: + options.debug = False + options.both = False + options.relwithdebug = False + if os.path.exists('REV.txt'): + os.unlink('REV.txt') + return options, args @@ -603,7 +615,7 @@ class CommandTimer(object): msg('Finished command: %s (%s)' % (self.name, time)) -def uploadPackage(fileName, mask=defaultMask, keep=50): +def uploadPackage(fileName, options, mask=defaultMask, keep=50): """ Upload the given filename to the configured package server location. Only the `keep` most recent files matching `mask` will be kept so the server @@ -618,29 +630,32 @@ def uploadPackage(fileName, mask=defaultMask, keep=50): # idenity file, etc needed for making an SSH connection to the # snapshots server. host = 'wxpython-rbot' - snapshotDir = 'snapshot-builds' + if options.release_build: + uploadDir = 'release-builds' + else: + uploadDir = 'snapshot-builds' # copy the new file to the server - cmd = 'scp {} {}:{}'.format(fileName, host, snapshotDir) - msg(cmd) + cmd = 'scp {} {}:{}'.format(fileName, host, uploadDir) + #msg(cmd) runcmd(cmd) # Make sure it is readable by all - cmd = 'ssh {} "cd {}; chmod a+r {}"'.format(host, snapshotDir, os.path.basename(fileName)) + cmd = 'ssh {} "cd {}; chmod a+r {}"'.format(host, uploadDir, os.path.basename(fileName)) runcmd(cmd) # get the list of all snapshot files on the server - cmd = 'ssh {} "cd {}; ls {}"'.format(host, snapshotDir, mask) + cmd = 'ssh {} "cd {}; ls {}"'.format(host, uploadDir, mask) allFiles = runcmd(cmd, getOutput=True) allFiles = allFiles.strip().split('\n') allFiles.sort() - # Leave the last keep builds, including this new one, on the server. + # Leave the last keep number of builds, including this new one, on the server. # Delete the rest. rmFiles = allFiles[:-keep] if rmFiles: msg("Deleting %s" % ", ".join(rmFiles)) - cmd = 'ssh {} "cd {}; rm {}"'.format(host, snapshotDir, " ".join(rmFiles)) + cmd = 'ssh {} "cd {}; rm {}"'.format(host, uploadDir, " ".join(rmFiles)) runcmd(cmd) msg("Upload complete!") @@ -936,7 +951,7 @@ def cmd_docs_bdist(options, args): tarball.close() if options.upload: - uploadPackage(tarfilename, keep=5, + uploadPackage(tarfilename, options, keep=5, mask='%s-docs-%s*' % (baseName, cfg.VER_MAJOR)) msg('Documentation tarball built at %s' % tarfilename) @@ -1359,7 +1374,7 @@ def cmd_bdist_egg(options, args): filemask = "dist/%s-%s-*.egg" % (baseName, cfg.VERSION.replace('-', '_')) filenames = glob.glob(filemask) assert len(filenames) == 1 - uploadPackage(filenames[0]) + uploadPackage(filenames[0], options) def cmd_bdist_wheel(options, args): @@ -1369,7 +1384,7 @@ def cmd_bdist_wheel(options, args): filemask = "dist/%s-%s-*.whl" % (baseName, cfg.VERSION.replace('-', '_')) filenames = glob.glob(filemask) assert len(filenames) == 1 - uploadPackage(filenames[0]) + uploadPackage(filenames[0], options) def cmd_bdist_wininst(options, args): @@ -1379,7 +1394,7 @@ def cmd_bdist_wininst(options, args): filemask = "dist/%s-%s-*.exe" % (baseName, cfg.VERSION.replace('-', '_')) filenames = glob.glob(filemask) assert len(filenames) == 1 - uploadPackage(filenames[0]) + uploadPackage(filenames[0], options) # bdist_msi requires the version number to be only 3 components, but we're @@ -1528,8 +1543,6 @@ def cmd_sdist(options, args): WDEST = posixjoin(PDEST, 'ext/wxWidgets') if not os.path.exists(PDEST): os.makedirs(PDEST) - #if not os.path.exists(WDEST): - # os.makedirs(WDEST) # and a place to put the final tarball if not os.path.exists('dist'): @@ -1561,8 +1574,6 @@ def cmd_sdist(options, args): copyFile('REV.txt', PDEST) # Add some extra stuff to the root folder - #copyFile('packaging/setup.py', ADEST) - #copyFile('packaging/README-sdist.txt', opj(ADEST, 'README.txt')) cmd_egg_info(options, args, egg_base=PDEST) copyFile(opj(PDEST, 'wxPython_Phoenix.egg-info/PKG-INFO'), opj(PDEST, 'PKG-INFO')) @@ -1583,7 +1594,7 @@ def cmd_sdist(options, args): shutil.rmtree(PDEST) if options.upload: - uploadPackage(tarfilename) + uploadPackage(tarfilename, options) msg("Source release built at %s" % tarfilename) @@ -1634,7 +1645,7 @@ def cmd_bdist(options, args): tarball.close() if options.upload: - uploadPackage(tarfilename) + uploadPackage(tarfilename, options) msg("Binary release built at %s" % tarfilename) @@ -1647,14 +1658,21 @@ def cmd_setrev(options, args): cmdTimer = CommandTimer('setrev') assert os.getcwd() == phoenixDir() - svnrev = getVcsRev() - f = open('REV.txt', 'w') - svnrev = '.dev'+svnrev - f.write(svnrev) - f.close() + if options.release_build: + # Ignore this command for release builds, they are not supposed to + # include current VCS revision info in the version number. + msg('This is a release build, setting REV.txt skipped') + + else: + svnrev = getVcsRev() + f = open('REV.txt', 'w') + svnrev = '.dev'+svnrev + f.write(svnrev) + f.close() + msg('REV.txt set to "%s"' % svnrev) + cfg = Config() cfg.resetVersion() - msg('REV.txt set to "%s"' % svnrev) msg('cfg.VERSION: %s' % cfg.VERSION)