Beispiel #1
0
def build_docs_and_install(name, version, findlinks):  # pragma no cover
    tdir = tempfile.mkdtemp()
    startdir = os.getcwd()
    os.chdir(tdir)
    try:
        tarpath = download_github_tar('OpenMDAO-Plugins', name, version)

        # extract the repo tar file
        tar = tarfile.open(tarpath)
        tar.extractall()
        tar.close()

        files = os.listdir('.')
        files.remove(os.path.basename(tarpath))
        if len(files) != 1:
            raise RuntimeError(
                "after untarring, found multiple directories: %s" % files)

        # build sphinx docs
        os.chdir(files[0])  # should be in distrib directory now
        check_call(['plugin', 'build_docs', files[0]])

        # create an sdist so we can query metadata for distrib dependencies
        check_call([sys.executable, 'setup.py', 'sdist', '-d', '.'])

        if sys.platform.startswith('win'):
            tars = fnmatch.filter(os.listdir('.'), "*.zip")
        else:
            tars = fnmatch.filter(os.listdir('.'), "*.tar.gz")
        if len(tars) != 1:
            raise RuntimeError("should have found a single archive file,"
                               " but found %s instead" % tars)

        check_call(['easy_install', '-NZ', tars[0]])

        # now install any dependencies
        metadict = get_metadata(tars[0])
        reqs = metadict.get('requires', [])
        done = set()

        while reqs:
            r = reqs.pop()
            if r not in done:
                done.add(r)
                ws = WorkingSet()
                req = Requirement.parse(r)
                dist = ws.find(req)
                if dist is None:
                    check_call(['easy_install', '-NZ', '-f', findlinks, r])
                    dist = ws.find(req)
                    if dist is None:
                        raise RuntimeError("Couldn't find distribution '%s'" %
                                           r)
                    dist.activate()
                    dct = get_metadata(dist.egg_name().split('-')[0])
                    for new_r in dct.get('requires', []):
                        reqs.append(new_r)
    finally:
        os.chdir(startdir)
        shutil.rmtree(tdir, ignore_errors=True)
Beispiel #2
0
def build_docs_and_install(name, version, findlinks):  # pragma no cover
    tdir = tempfile.mkdtemp()
    startdir = os.getcwd()
    os.chdir(tdir)
    try:
        tarpath = download_github_tar('OpenMDAO-Plugins', name, version)
        
        # extract the repo tar file
        tar = tarfile.open(tarpath)
        tar.extractall()
        tar.close()
        
        files = os.listdir('.')
        files.remove(os.path.basename(tarpath))
        if len(files) != 1:
            raise RuntimeError("after untarring, found multiple directories: %s"
                               % files)
        
        # build sphinx docs
        os.chdir(files[0]) # should be in distrib directory now
        check_call(['plugin', 'build_docs', files[0]])
        
        # create an sdist so we can query metadata for distrib dependencies
        check_call([sys.executable, 'setup.py', 'sdist', '-d', '.'])
        
        if sys.platform.startswith('win'):
            tars = fnmatch.filter(os.listdir('.'), "*.zip")
        else:
            tars = fnmatch.filter(os.listdir('.'), "*.tar.gz")
        if len(tars) != 1:
            raise RuntimeError("should have found a single archive file,"
                               " but found %s instead" % tars)

        check_call(['easy_install', '-NZ', tars[0]])
        
        # now install any dependencies
        metadict = get_metadata(tars[0])
        reqs = metadict.get('requires', [])
        done = set()
        
        while reqs:
            r = reqs.pop()
            if r not in done:
                done.add(r)
                ws = WorkingSet()
                req = Requirement.parse(r)
                dist = ws.find(req)
                if dist is None:
                    check_call(['easy_install', '-NZ', '-f', findlinks, r])
                    dist = ws.find(req)
                    if dist is None:
                        raise RuntimeError("Couldn't find distribution '%s'" % r)
                    dist.activate()
                    dct = get_metadata(dist.egg_name().split('-')[0])
                    for new_r in dct.get('requires', []):
                        reqs.append(new_r)
    finally:
        os.chdir(startdir)
        shutil.rmtree(tdir, ignore_errors=True)
Beispiel #3
0
def build_docs_and_install(name, version, findlinks):  # pragma no cover
    tdir = tempfile.mkdtemp()
    startdir = os.getcwd()
    os.chdir(tdir)
    try:
        tarpath = download_github_tar('OpenMDAO-Plugins', name, version)

        # extract the repo tar file
        tar = tarfile.open(tarpath)
        tar.extractall()
        tar.close()

        files = os.listdir('.')
        files.remove(os.path.basename(tarpath))
        if len(files) != 1:
            raise RuntimeError("after untarring, found multiple directories: %s"
                               % files)

        os.chdir(files[0])  # should be in distrib directory now

        cfg = SafeConfigParser(dict_type=OrderedDict)
        cfg.readfp(open('setup.cfg', 'r'), 'setup.cfg')
        if cfg.has_option('metadata', 'requires-dist'):
            reqs = cfg.get('metadata', 'requires-dist').strip()
            reqs = reqs.replace(',', ' ')
            reqs = [n.strip() for n in reqs.split()]
        else:
            # couldn't find requires-dist in setup.cfg, so
            # create an sdist so we can query metadata for distrib dependencies
            tarname = _bld_sdist_and_install(deps=False)

            # now find any dependencies
            metadict = get_metadata(tarname)
            reqs = metadict.get('requires', [])

        # install dependencies (some may be needed by sphinx)
        ws = WorkingSet()
        for r in reqs:
            print "Installing dependency '%s'" % r
            req = Requirement.parse(r)
            dist = ws.find(req)
            if dist is None:
                try:
                    check_call(['easy_install', '-Z', '-f', findlinks, r])
                except Exception:
                    traceback.print_exc()

        # build sphinx docs
        check_call(['plugin', 'build_docs', files[0]])

        # make a new sdist with docs in it and install it
        tarname = _bld_sdist_and_install()
    finally:
        os.chdir(startdir)
        shutil.rmtree(tdir, ignore_errors=True)
Beispiel #4
0
def build_docs_and_install(name, version, findlinks):  # pragma no cover
    tdir = tempfile.mkdtemp()
    startdir = os.getcwd()
    os.chdir(tdir)
    try:
        tarpath = download_github_tar('OpenMDAO-Plugins', name, version)

        # extract the repo tar file
        tar = tarfile.open(tarpath)
        tar.extractall()
        tar.close()

        files = os.listdir('.')
        files.remove(os.path.basename(tarpath))
        if len(files) != 1:
            raise RuntimeError("after untarring, found multiple directories: %s"
                               % files)

        os.chdir(files[0])  # should be in distrib directory now

        cfg = SafeConfigParser(dict_type=OrderedDict)
        cfg.readfp(open('setup.cfg', 'r'), 'setup.cfg')
        if cfg.has_option('metadata', 'requires-dist'):
            reqs = cfg.get('metadata', 'requires-dist').strip()
            reqs = reqs.replace(',', ' ')
            reqs = [n.strip() for n in reqs.split()]
        else:
            # couldn't find requires-dist in setup.cfg, so
            # create an sdist so we can query metadata for distrib dependencies
            tarname = _bld_sdist_and_install(deps=False)

            # now find any dependencies
            metadict = get_metadata(tarname)
            reqs = metadict.get('requires', [])

        # install dependencies (some may be needed by sphinx)
        ws = WorkingSet()
        for r in reqs:
            print "Installing dependency '%s'" % r
            req = Requirement.parse(r)
            dist = ws.find(req)
            if dist is None:
                try:
                    check_call(['easy_install', '-Z', '-f', findlinks, r])
                except Exception:
                    traceback.print_exc()

        # build sphinx docs
        check_call(['plugin', 'build_docs', files[0]])

        # make a new sdist with docs in it and install it
        tarname = _bld_sdist_and_install()
    finally:
        os.chdir(startdir)
        shutil.rmtree(tdir, ignore_errors=True)
def test_commit(payload):
    """Run the test suite on the commit specified in payload."""
    
    startdir = os.getcwd()
    
    repo = payload['repository']['url']
    commit_id = payload['after']
    branch = payload['ref'].split('/')[-1]
    
    if repo != REPO_URL:
        log('ignoring commit: repo URL %s does not match expected repo URL (%s)' % (repo, REPO_URL))
        return -1
    
    if branch not in REPO_BRANCHES:
        log('branch is %s' % branch)
        log('ignoring commit %s: branch is not one of %s' % (commit_id,
                                                             REPO_BRANCHES))
        return -1
    
    # make sure this commit hasn't been tested yet
    cmnts = model.get_host_tests(commit_id)
    if cmnts != None and len(list(cmnts)) > 0:
        log("commit %s has already been tested" % commit_id)
        return -1
    
    commit_dir = get_commit_dir(commit_id)
    tmp_results_dir = os.path.join(commit_dir, 'host_results')
    tmp_repo_dir = os.path.join(commit_dir, 'repo')
    os.makedirs(tmp_results_dir)
    os.makedirs(tmp_repo_dir)
    
    # grab a copy of the commit
    log("downloading source tarball from github for commit %s" % commit_id)
    prts = repo.split('/')
    repo_name = prts[-1]
    org_name = prts[-2]
    tarpath = download_github_tar(org_name, repo_name, commit_id, dest=tmp_repo_dir)

    cmd = ['openmdao', 'test_branch', 
           '-o', tmp_results_dir,
           '-f', tarpath,
           ]
    for host in HOSTS:
        cmd.append('--host=%s' % host)
        
    if TEST_ARGS:
        cmd.append('--testargs="%s"' % ' '.join(TEST_ARGS))
    
    try:
        log('cmd = %s' % ' '.join(cmd))
        out, ret = _run_sub(cmd, env=os.environ.copy(), cwd=os.getcwd())
        log('test_branch return code = %s' % ret)

        process_results(commit_id, ret, tmp_results_dir, out)
    except (Exception, SystemExit) as err:
        log('ERROR during local build: %s' % str(err))
        ret = -1
        process_results(commit_id, ret, tmp_results_dir, str(err))
    finally:
        d = get_commit_dir(commit_id)
        del directory_map[commit_id]
        log('removing temp commit directory %s' % d)
        shutil.rmtree(d)
        
    return ret
def build_docs_and_install(owner, name, version, findlinks):  # pragma no cover
    tdir = tempfile.mkdtemp()
    startdir = os.getcwd()
    os.chdir(tdir)
    try:
        tarpath = download_github_tar(owner, name, version)

        # extract the repo tar file
        tar = tarfile.open(tarpath)
        tar.extractall()
        tar.close()

        files = os.listdir(".")
        files.remove(os.path.basename(tarpath))
        if len(files) != 1:
            raise RuntimeError("after untarring, found multiple directories: %s" % files)

        os.chdir(files[0])  # should be in distrib directory now

        cfg = SafeConfigParser(dict_type=OrderedDict)

        try:
            cfg.readfp(open("setup.cfg", "r"), "setup.cfg")

        except IOError as io_error:
            raise IOError, "OpenMDAO plugins must have a setup.cfg: {}".format(io_error), sys.exc_info()[2]

        try:
            reqs = cfg.get("metadata", "requires-dist").strip()
            reqs = reqs.replace(",", " ")
            reqs = [n.strip() for n in reqs.split()]

            try:
                flinks = cfg.get("easy_install", "find_links").strip()
                flinks = flinks.split("\n")
                flinks = [n.strip() for n in flinks]

                flinks.append(findlinks)

                findlinks = " ".join(flinks)

            except (NoSectionError, NoOptionError):
                pass

        except NoOptionError:
            # couldn't find requires-dist in setup.cfg, so
            # create an sdist so we can query metadata for distrib dependencies
            tarname = _bld_sdist_and_install(deps=False)

            # now find any dependencies
            metadict = get_metadata(tarname)
            reqs = metadict.get("requires", [])

        # install dependencies (some may be needed by sphinx)
        ws = WorkingSet()
        for r in reqs:
            print "Installing dependency '%s'" % r
            req = Requirement.parse(r)
            dist = ws.find(req)
            if dist is None:
                try:
                    check_call(["easy_install", "-Z", "-f", findlinks, r])
                except Exception:
                    traceback.print_exc()

        # build sphinx docs
        check_call(["plugin", "build_docs", files[0]])

        # make a new sdist with docs in it and install it
        tarname = _bld_sdist_and_install()
    finally:
        os.chdir(startdir)
        shutil.rmtree(tdir, ignore_errors=True)