Example #1
0
def list_testhosts(parser, options, args=None):
    if args:
        print_sub_help(parser, 'list_testhosts')
        return -1
    hostlist, config = read_config(options)
    for host in filter_config(hostlist, config, options):
        plat = config.get(host, 'platform')
        py = config.get(host, 'py')
        print host.ljust(30), plat.ljust(10), py
Example #2
0
def list_testhosts(parser, options, args=None):
    if args:
        print_sub_help(parser, 'list_testhosts')
        return -1
    hostlist, config = read_config(options)
    for host in filter_config(hostlist, config, options):
        plat = config.get(host, 'platform')
        py = config.get(host, 'py')
        print host.ljust(30), plat.ljust(10), py
def process_options(options):
    """Handles some config-related options so that the code
    doesn't have to be duplicated in multiple parsers.
    """
    hostlist, config = read_config(options)
    hosts = filter_config(hostlist, config, options)

    # find out which hosts are ec2 images, if any
    ec2_hosts = set()
    ec2_needed = False
    for host in hosts:
        if config.has_option(host, 'image_id'):
            ec2_hosts.add(host)
            ec2_needed = True
        elif config.has_option(host, 'instance_id'):
            ec2_needed = True

    if ec2_needed:
        from boto.ec2.connection import EC2Connection
        print 'connecting to EC2'
        conn = EC2Connection()
    else:
        conn = None

    for host in hosts:
        if host not in ec2_hosts and not config.has_option(host, 'addr'):
            if not config.has_option(host, 'instance_id'):
                raise RuntimeError("can't determine address for host %s" %
                                   host)

            # use instance_id to look up public dns name
            instance_id = config.get(host, 'instance_id')
            reslist = conn.get_all_instances([instance_id])
            if len(reslist) > 0:
                inst = reslist[0].instances[0]
            else:
                raise RuntimeError("can't find a running instance of host %s" %
                                   host)
            if inst.state == u'stopped':
                ec2_hosts.add(host)
            else:
                config.set(host, 'addr', inst.public_dns_name)

    options.hosts = hosts

    options.outdir = os.path.abspath(
        os.path.expanduser(os.path.expandvars(options.outdir)))

    return (config, conn, ec2_hosts)
def process_options(options):
    """Handles some config-related options so that the code
    doesn't have to be duplicated in multiple parsers.
    """
    hostlist, config = read_config(options)
    hosts = filter_config(hostlist, config, options)
        
    # find out which hosts are ec2 images, if any
    ec2_hosts = set()
    ec2_needed = False
    for host in hosts:
        if config.has_option(host, 'image_id'):
            ec2_hosts.add(host)
            ec2_needed = True
        elif config.has_option(host, 'instance_id'):
            ec2_needed = True

    if ec2_needed:
        from boto.ec2.connection import EC2Connection
        print 'connecting to EC2'
        conn = EC2Connection()
    else:
        conn = None

    for host in hosts:
        if host not in ec2_hosts and not config.has_option(host, 'addr'):
            if not config.has_option(host, 'instance_id'):
                raise RuntimeError("can't determine address for host %s" % host)
            
            # use instance_id to look up public dns name
            instance_id = config.get(host, 'instance_id')
            reslist = conn.get_all_instances([instance_id])
            if len(reslist) > 0:
                inst = reslist[0].instances[0]
            else:
                raise RuntimeError("can't find a running instance of host %s" % host)
            if inst.state == u'stopped':
                ec2_hosts.add(host)
            else:
                config.set(host, 'addr', inst.public_dns_name)
            
    options.hosts = hosts
    
    options.outdir = os.path.abspath(os.path.expanduser(
                                     os.path.expandvars(options.outdir)))

    return (config, conn, ec2_hosts)
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)
Example #6
0
def list_testhosts(options):
    hostlist, config = read_config(options)
    for host in filter_config(hostlist, config, options):
        plat = config.get(host, 'platform')
        py = config.get(host, 'py')
        print host.ljust(30), plat.ljust(10), py
Example #7
0
def list_testhosts(options):
    hostlist, config = read_config(options)
    for host in filter_config(hostlist, config, options):
        plat = config.get(host, 'platform')
        py = config.get(host, 'py')
        print host.ljust(30), plat.ljust(10), py
Example #8
0
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)