def finalize_release(parser, options): """Push the specified release up to the production server and tag the repository with the version number. """ if options.version is None: raise RuntimeError("you must specify the version") reldir = 'rel_%s' % options.version brname = 'release_%s' % options.version # check validity if not os.path.isdir(reldir): raise RuntimeError( "release directory %s was not found. Did you run 'release build'?" % reldir) for f in os.listdir(reldir): if os.path.isdir(os.path.join(reldir, f)) and f != 'docs': raise RuntimeError( "release directory is not flat. You must call 'release finalize' on the directory built by 'release build'" ) if brname not in get_git_branches(): raise RuntimeError( "branch %s doesn't exist. Did you run 'release build'?" % brname) if _has_checkouts(): raise RuntimeError("the current branch still has uncommitted files") start_branch = get_git_branch() try: print "checking out branch %s" % brname check_call(['git', 'checkout', brname]) if _has_checkouts(): raise RuntimeError("branch %s still has uncommitted files" % brname) # push files up to openmdao.org print "pushing release files up to openmdao.org" if options.dry_run: print 'skipping...' else: check_call( ['release', 'push', reldir, '*****@*****.**']) # push release files to official repo on github (master branch) print "pushing branch %s up to the official master branch" % brname if options.dry_run: print 'skipping...' else: check_call( ['git', 'push', '--tags', 'origin', '%s:master' % brname]) finally: print 'returning to original branch (%s)' % start_branch check_call(['git', 'checkout', start_branch])
def finalize_release(parser, options): """Push the specified release up to the production server and tag the repository with the version number. """ if options.version is None: raise RuntimeError("you must specify the version") reldir = 'rel_%s' % options.version brname = 'release_%s' % options.version # check validity if not os.path.isdir(reldir): raise RuntimeError("release directory %s was not found. Did you run 'release build'?" % reldir) for f in os.listdir(reldir): if os.path.isdir(os.path.join(reldir, f)) and f != 'docs': raise RuntimeError("release directory is not flat. You must call 'release finalize' on the directory built by 'release build'") if brname not in get_git_branches(): raise RuntimeError("branch %s doesn't exist. Did you run 'release build'?" % brname) if _has_checkouts(): raise RuntimeError("the current branch still has uncommitted files") start_branch = get_git_branch() try: print "checking out branch %s" % brname check_call(['git', 'checkout', brname]) if _has_checkouts(): raise RuntimeError("branch %s still has uncommitted files" % brname) # push files up to openmdao.org print "pushing release files up to openmdao.org" if options.dry_run: print 'skipping...' else: check_call(['release', 'push', reldir, '*****@*****.**']) # push release files to official repo on github (master branch) print "pushing branch %s up to the official master branch" % brname if options.dry_run: print 'skipping...' else: check_call(['git', 'push', '--tags', 'origin', '%s:master' % brname]) finally: print 'returning to original branch (%s)' % start_branch check_call(['git', 'checkout', start_branch])
def build_release(parser, options): """Create an OpenMDAO release, placing the following files in the specified destination directory: - source distribs of all of the openmdao subpackages - binary eggs for openmdao subpackages with compiled code - an installer script for the released version of openmdao that will create a virtualenv and populate it with all of the necessary dependencies needed to use openmdao - Sphinx documentation in html To run this, you must be in a Git repository with no uncommitted changes. If not running with the ``--test`` option, a release branch will be created from the specified base branch, and in the process of running, a number of ``releaseinfo.py`` files will be updated with new version information and committed. """ if options.version is None: parser.print_usage() print "version was not specified" sys.exit(-1) if options.destdir is None: options.destdir = "rel_%s" % options.version _check_version(options.version) options.cfg = os.path.expanduser(options.cfg) hostlist, config = read_config(options) required_binaries = set([('windows', 'python2.6'), ('windows', 'python2.7')]) binary_hosts = set() if options.binaries: for host in hostlist: if config.has_section(host): if config.has_option(host, 'build_binaries') and config.getboolean(host, 'build_binaries'): platform = _get_cfg_val(config, host, 'platform') py = _get_cfg_val(config, host, 'py') if (platform, py) in required_binaries: required_binaries.remove((platform, py)) binary_hosts.add(host) if sys.platform == 'darwin': # build osx binaries if we're on a mac binary_hosts.add('localhost') elif required_binaries and sys.platform.startswith('win'): try: required_binaries.remove(('windows', 'python%d.%d' % (sys.version_info[0:2]))) except: pass else: binary_hosts.add('localhost') if required_binaries: print "WARNING: binary distributions are required for the following and no hosts were specified: %s" % list(required_binaries) if not options.test: print 'aborting...' sys.exit(-1) orig_branch = get_git_branch() if not orig_branch: print "You must make a release from within a git repository. aborting" sys.exit(-1) if not options.test: if orig_branch != options.base: print "Your current branch '%s', is not the specified base branch '%s'" % (orig_branch, options.base) sys.exit(-1) if _has_checkouts(): print "There are uncommitted changes. You must create a release from a clean branch" sys.exit(-1) if orig_branch == 'dev': print "pulling dev branch from origin..." os.system("git pull origin %s" % orig_branch) if _has_checkouts(): print "something went wrong during pull. aborting" sys.exit(-1) else: print "WARNING: base branch is not 'dev' so it has not been" print "automatically brought up-to-date." answer = raw_input("Proceed? (Y/N) ") if answer.lower() not in ["y", "yes"]: sys.exit(-1) relbranch = "release_%s" % options.version if relbranch in get_git_branches(): print "release branch %s already exists in this repo" % relbranch sys.exit(-1) print "creating release branch '%s' from base branch '%s'" % (relbranch, orig_branch) check_call(['git', 'branch', relbranch]) print "checking out branch '%s'" % relbranch check_call(['git', 'checkout', relbranch]) destdir = os.path.abspath(options.destdir) if not os.path.exists(destdir): os.makedirs(destdir) startdir = os.getcwd() topdir = repo_top() cfgpath = os.path.expanduser(options.cfg) try: _update_releaseinfo_files(options.version) # build the docs docdir = os.path.join(topdir, 'docs') idxpath = os.path.join(docdir, '_build', 'html', 'index.html') if not os.path.isfile(idxpath) or not options.nodocbuild: build_docs(parser, options) shutil.copytree(os.path.join(topdir,'docs','_build', 'html'), os.path.join(destdir,'docs')) shutil.copytree(os.path.join(topdir,'docs','_build', 'html'), os.path.join(topdir,'openmdao.main', 'src', 'openmdao', 'main', 'docs')) if not options.test: # commit the changes to the release branch print "committing all changes to branch '%s'" % relbranch check_call(['git', 'commit', '-a', '-m', '"updating releaseinfo files for release %s"' % options.version]) # build openmdao package distributions proj_dirs = [] for project_name, pdir, pkgtype in openmdao_packages: pdir = os.path.join(topdir, pdir, project_name) if 'src' in os.listdir(pdir): os.chdir(os.path.join(pdir, 'src')) else: os.chdir(pdir) print 'building %s' % project_name _build_sdist(pdir, destdir, options.version) if pkgtype == 'bdist_egg': proj_dirs.append(pdir) os.chdir(startdir) _build_bdist_eggs(proj_dirs, destdir, list(binary_hosts), cfgpath) print 'creating bootstrapping installer script go-openmdao.py' installer = os.path.join(os.path.dirname(__file__), 'mkinstaller.py') check_call([sys.executable, installer, '--dest=%s'%destdir]) if options.comment: comment = options.comment else: comment = 'creating release %s' % options.version if not options.test: # tag the current revision with the release version id print "tagging release with '%s'" % options.version check_call(['git', 'tag', '-f', '-a', options.version, '-m', comment]) check_call(['git', 'checkout', orig_branch]) print "\n*REMEMBER* to push '%s' up to the master branch if this release is official" % relbranch print "new release files have been placed in %s" % destdir finally: if options.test: _rollback_releaseinfo_files() #Cleanup shutil.rmtree(os.path.join(topdir, "openmdao.main", 'src', 'openmdao', 'main', "docs")) os.chdir(startdir)
def finalize_release(parser, options): """Push the specified release up to the production server and tag the repository with the version number. """ if options.version is None: raise RuntimeError("you must specify the version") if options.tutorials: if not uploadGists(options.version): print "" print "Did not upload tutorials to GitHub" else: print "Successfully uploaded tutorials to GitHub" print "Only uploaded tutorials, no other action was taken. Now exiting" sys.exit(0) reldir = 'rel_%s' % options.version brname = 'release_%s' % options.version # check validity if not os.path.isdir(reldir): raise RuntimeError("release directory %s was not found. Did you run 'release build'?" % reldir) for f in os.listdir(reldir): if os.path.isdir(os.path.join(reldir, f)) and f != 'docs': raise RuntimeError("release directory is not flat. You must call 'release finalize' on the directory built by 'release build'") if brname not in get_git_branches(): raise RuntimeError("branch %s doesn't exist. Did you run 'release build'?" % brname) if _has_checkouts(): raise RuntimeError("the current branch still has uncommitted files") start_branch = get_git_branch() try: print "checking out branch %s" % brname check_call(['git', 'checkout', brname]) if _has_checkouts(): raise RuntimeError("branch %s still has uncommitted files" % brname) # push files up to openmdao.org print "pushing release files up to openmdao.org" if options.dry_run: print 'skipping...' else: check_call(['release', 'push', reldir, '*****@*****.**']) # push release files to official repo on github (dev branch) print "pushing branch %s up to the official dev branch" % brname if options.dry_run: print 'skipping...' else: check_call(['git', 'push', '--tags', 'origin', '%s:dev' % brname]) # push tutorials to github print "uploading tutorials and examples to GitHub and Cookbook" if options.dry_run or options.nogists: print' skipping...' else: if not uploadGists(options.version): print "" print "Did not upload tutorials to GitHub" else: print "Successfully uploaded tutorials to GitHub" finally: print 'returning to original branch (%s)' % start_branch check_call(['git', 'checkout', start_branch])
def build_release(parser, options): """Create an OpenMDAO release, placing the following files in the specified destination directory: - source distribs of all of the openmdao subpackages - binary eggs for openmdao subpackages with compiled code - an installer script for the released version of openmdao that will create a virtualenv and populate it with all of the necessary dependencies needed to use openmdao - Sphinx documentation in html To run this, you must be in a Git repository with no uncommitted changes. If not running with the ``--test`` option, a release branch will be created from the specified base branch, and in the process of running, a number of ``releaseinfo.py`` files will be updated with new version information and committed. """ if options.version is None: parser.print_usage() print "version was not specified" sys.exit(-1) if options.destdir is None: options.destdir = "rel_%s" % options.version _check_version(options.version) options.cfg = os.path.expanduser(options.cfg) hostlist, config = read_config(options) required_binaries = set([('windows', 'python2.7')]) binary_hosts = set() if options.binaries: for host in hostlist: if config.has_section(host): if config.has_option(host, 'build_binaries') and config.getboolean( host, 'build_binaries'): platform = _get_cfg_val(config, host, 'platform') py = _get_cfg_val(config, host, 'py') if (platform, py) in required_binaries: required_binaries.remove((platform, py)) binary_hosts.add(host) if sys.platform == 'darwin': # build osx binaries if we're on a mac binary_hosts.add('localhost') elif required_binaries and sys.platform.startswith('win'): try: required_binaries.remove( ('windows', 'python%d.%d' % (sys.version_info[0:2]))) except: pass else: binary_hosts.add('localhost') if required_binaries: print "WARNING: binary distributions are required for the following and no hosts were specified: %s" % list( required_binaries) if not options.test: print 'aborting...' sys.exit(-1) orig_branch = get_git_branch() if not orig_branch: print "You must make a release from within a git repository. aborting" sys.exit(-1) if not options.test: if orig_branch != options.base: print "Your current branch '%s', is not the specified base branch '%s'" % ( orig_branch, options.base) sys.exit(-1) if _has_checkouts(): print "There are uncommitted changes. You must create a release from a clean branch" sys.exit(-1) if orig_branch == 'master': print "pulling master branch from origin..." os.system("git pull origin %s" % orig_branch) if _has_checkouts(): print "something went wrong during pull. aborting" sys.exit(-1) else: print "WARNING: base branch is not 'master' so it has not been" print "automatically brought up-to-date." answer = raw_input("Proceed? (Y/N) ") if answer.lower() not in ["y", "yes"]: sys.exit(-1) relbranch = "release_%s" % options.version if relbranch in get_git_branches(): print "release branch %s already exists in this repo" % relbranch sys.exit(-1) print "creating release branch '%s' from base branch '%s'" % ( relbranch, orig_branch) check_call(['git', 'branch', relbranch]) print "checking out branch '%s'" % relbranch check_call(['git', 'checkout', relbranch]) destdir = os.path.abspath(options.destdir) if not os.path.exists(destdir): os.makedirs(destdir) startdir = os.getcwd() topdir = repo_top() cfgpath = os.path.expanduser(options.cfg) try: _update_releaseinfo_files(options.version) # build the docs docdir = os.path.join(topdir, 'docs') idxpath = os.path.join(docdir, '_build', 'html', 'index.html') if not os.path.isfile(idxpath) or not options.nodocbuild: build_docs(parser, options) shutil.copytree(os.path.join(topdir, 'docs', '_build', 'html'), os.path.join(destdir, 'docs')) shutil.copytree( os.path.join(topdir, 'docs', '_build', 'html'), os.path.join(topdir, 'openmdao.main', 'src', 'openmdao', 'main', 'docs')) if not options.test: # commit the changes to the release branch print "committing all changes to branch '%s'" % relbranch check_call([ 'git', 'commit', '-a', '-m', '"updating releaseinfo files for release %s"' % options.version ]) # build openmdao package distributions proj_dirs = [] for project_name, pdir, pkgtype in openmdao_packages: pdir = os.path.join(topdir, pdir, project_name) if 'src' in os.listdir(pdir): os.chdir(os.path.join(pdir, 'src')) else: os.chdir(pdir) print 'building %s' % project_name _build_sdist(pdir, destdir, options.version) if pkgtype == 'bdist_egg': proj_dirs.append(pdir) os.chdir(startdir) _build_bdist_eggs(proj_dirs, destdir, list(binary_hosts), cfgpath) print 'creating bootstrapping installer script go-openmdao-%s.py' % options.version installer = os.path.join(os.path.dirname(__file__), 'mkinstaller.py') check_call([sys.executable, installer, '--dest=%s' % destdir]) if options.comment: comment = options.comment else: comment = 'creating release %s' % options.version if not options.test: # tag the current revision with the release version id print "tagging release with '%s'" % options.version check_call( ['git', 'tag', '-f', '-a', options.version, '-m', comment]) check_call(['git', 'checkout', orig_branch]) print "\n*REMEMBER* to push '%s' up to the master branch if this release is official" % relbranch print "new release files have been placed in %s" % destdir finally: if options.test: _rollback_releaseinfo_files() # Cleanup try: shutil.rmtree( os.path.join(topdir, "openmdao.main", 'src', 'openmdao', 'main', "docs")) except: pass os.chdir(startdir)
def make_release(): """Create an OpenMDAO release, placing the following files in the specified destination directory: - source distribs of all of the openmdao subpackages - binary eggs for openmdao subpackages with compiled code - an installer script for the released version of openmdao that will create a virtualenv and populate it with all of the necessary dependencies needed to use openmdao - Sphinx documentation in html In order to run this, you must be in a git repository with no uncommitted changes. If not running with the --test option, a release branch will be created from the specified base branch, and in the process of running, a number of releaseinfo.py files will be updated with new version information and committed. """ parser = OptionParser() parser.add_option("-d", "--destination", action="store", type="string", dest="destdir", help="directory where distributions and docs will be placed") parser.add_option("-v", "--version", action="store", type="string", dest="version", help="version string applied to all openmdao distributions") parser.add_option("-m", action="store", type="string", dest="comment", help="optional comment for version tag") parser.add_option("-b", "--basebranch", action="store", type="string", dest="base", default='master', help="base branch for release. defaults to master") parser.add_option("-t", "--test", action="store_true", dest="test", help="used for testing. A release branch will not be created") parser.add_option("-n", "--nodocbuild", action="store_true", dest="nodocbuild", help="used for testing. The docs will not be rebuilt if they already exist") parser.add_option("--host", action='append', dest='hosts', metavar='HOST', default=[], help="host from config file to build bdist_eggs on. " "Multiple --host args are allowed.") parser.add_option("-c", "--config", action='store', dest='cfg', metavar='CONFIG', default='~/.openmdao/testhosts.cfg', help="path of config file where info for hosts is located") (options, args) = parser.parse_args(sys.argv[1:]) if not options.version or not options.destdir: parser.print_help() sys.exit(-1) _check_version(options.version) options.cfg = os.path.expanduser(options.cfg) config = ConfigParser.ConfigParser() config.readfp(open(options.cfg)) haswin = False for host in options.hosts: if host == 'localhost': if sys.platform.startswith('win'): haswin = True elif config.has_section(host): platform = config.get(host, 'platform') if platform == 'windows': haswin = True if not haswin: print "no windows host was specified, so can't build binary eggs for windows" sys.exit(-1) orig_branch = get_git_branch() if not orig_branch: print "You must run mkrelease from within a git repository. aborting" sys.exit(-1) if not options.test: if orig_branch != options.base: print "Your current branch '%s', is not the specified base branch '%s'" % (orig_branch, options.base) sys.exit(-1) if _has_checkouts(): print "There are uncommitted changes. You must run mkrelease.py from a clean branch" sys.exit(-1) if orig_branch == 'master': print "pulling master" os.system("git pull origin master") if _has_checkouts(): print "something went wrong during pull. aborting" sys.exit(-1) else: print "WARNING: base branch is not 'master' so it has not been" print "automatically brought up-to-date." answer = raw_input("Proceed? (Y/N) ") if answer.lower() not in ["y", "yes"]: sys.exit(-1) relbranch = "release_%s" % options.version if relbranch in get_git_branches(): print "release branch %s already exists in this repo" % relbranch sys.exit(-1) print "creating release branch '%s' from base branch '%s'" % (relbranch, orig_branch) check_call(['git', 'branch', relbranch]) print "checking out branch '%s'" % relbranch check_call(['git', 'checkout', relbranch]) destdir = os.path.abspath(options.destdir) if not os.path.exists(destdir): os.makedirs(destdir) startdir = os.getcwd() topdir = repo_top() cfgpath = os.path.expanduser(options.cfg) try: _update_releaseinfo_files(options.version) # build the docs docdir = os.path.join(topdir, 'docs') idxpath = os.path.join(docdir, '_build', 'html', 'index.html') if not os.path.isfile(idxpath) or not options.nodocbuild: build_docs(argv=['-v', options.version]) shutil.copytree(os.path.join(topdir,'docs','_build', 'html'), os.path.join(destdir,'docs')) if not options.test: # commit the changes to the release branch print "committing all changes to branch '%s'" % relbranch check_call(['git', 'commit', '-a', '-m', '"updating releaseinfo files for release %s"' % options.version]) # build openmdao package distributions proj_dirs = [] for project_name, pdir, pkgtype in openmdao_packages: pdir = os.path.join(topdir, pdir, project_name) if 'src' in os.listdir(pdir): os.chdir(os.path.join(pdir, 'src')) else: os.chdir(pdir) print 'building %s' % project_name _build_sdist(pdir, destdir, options.version) if pkgtype == 'bdist_egg': proj_dirs.append(pdir) os.chdir(startdir) _build_bdist_eggs(proj_dirs, destdir, options.hosts, cfgpath) print 'creating bootstrapping installer script go-openmdao.py' installer = os.path.join(os.path.dirname(__file__), 'mkinstaller.py') check_call([sys.executable, installer, '--dest=%s'%destdir]) if options.comment: comment = options.comment else: comment = 'creating release %s' % options.version if options.test: _rollback_releaseinfo_files() else: # tag the current revision with the release version id print "tagging release with '%s'" % options.version check_call(['git', 'tag', '-f', '-a', options.version, '-m', comment]) check_call(['git', 'checkout', orig_branch]) print "\n*REMEMBER* to push '%s' up to the master branch if this release is official" % relbranch print "new release files have been placed in %s" % destdir finally: os.chdir(startdir)