Example #1
0
def push_docs(options, args=None):
    """A script (push_docs) points to this. By default it pushes the current
    copy of the docs up to the development doc area on openmdao.org.
    """
    from fabric.api import run, put, cd, settings
    atexit.register(fabric_cleanup, True)

    host = options.host

    startdir = os.getcwd()
    branchdir = dirname(dirname(dirname(sys.executable)))
    docdir = join(branchdir, 'docs')
    idxpath = join(docdir, '_build', 'html', 'index.html')
    
    if not os.path.isfile(idxpath) or not options.nodocbuild:
        build_docs()

    os.chdir(join(docdir, '_build'))
    tarpath = tar_dir('html', 'docs', '.')
    tarname = os.path.basename(tarpath)
    
    with settings(host_string=host):
        # tar up the docs so we can upload them to the server
        # put the docs on the server and untar them
        put(tarpath, '%s/%s' % (options.docdir, tarname))
        with cd(options.docdir):
            run('tar xzf %s' % tarname)
            run('rm -rf dev_docs')
            run('mv html dev_docs')
            run('rm -f %s' % tarname)
Example #2
0
def push_docs():
    """A script (push_docs) points to this. It pushes the current copy of the docs up
    to the development doc area on openmdao.org.
    """
    startdir = os.getcwd()
    branchdir = dirname(dirname(dirname(sys.executable)))
    docdir = join(branchdir, 'docs')
    idxpath = join(docdir, '_build', 'html', 'index.html')
    if not os.path.isfile(idxpath):
        build_docs()

    try:
        os.chdir(join(docdir, '_build'))
        try:
            if exists('docs.tar.gz'):
                os.remove('docs.tar.gz')
            archive = tarfile.open('docs.tar.gz', 'w:gz')
            archive.add('html')
            archive.close()
        finally:
            os.chdir(startdir)
        
        with settings(host_string='*****@*****.**'):
            # tar up the docs so we can upload them to the server
            # put the docs on the server and untar them
            put(join(docdir,'_build','docs.tar.gz'), 'downloads/docs.tar.gz')
            with cd('downloads'):
                run('tar xzf docs.tar.gz')
                run('rm -rf dev_docs')
                run('mv html dev_docs')
                run('rm -f docs.tar.gz')
    finally:
        for key in connections.keys():
            connections[key].close()
            del connections[key]
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 #4
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)
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)