def print_summary(summary):
    print('-' * 70)
    for notebook, result in summary:
        if result is None:
            status('SKIP: ' + notebook)
        elif result:
            success(notebook)
        else:
            error(notebook)
    print('-' * 70)
Exemple #2
0
def conda_upload(files):
    uploaded = []
    for fname in files:
        try:
            system(['anaconda', 'upload', '--no-progress', '--force',
                    '--channel', 'nightly', '--user', 'csdms', fname])
        except CalledProcessError:
            pass
        else:
            success('uploaded: {fname}'.format(fname=fname))
    return uploaded
def conda_upload(files):
    uploaded = []
    for fname in files:
        try:
            system([
                'anaconda', 'upload', '--no-progress', '--force', '--channel',
                'nightly', '--user', 'csdms', fname
            ])
        except CalledProcessError:
            pass
        else:
            success('uploaded: {fname}'.format(fname=fname))
    return uploaded
def main():
    parser = argparse.ArgumentParser(
        description='Build the CSDMS software stack',
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    parser.add_argument('recipe', nargs='*', help='recipes to build')
    parser.add_argument('--cache-dir',
                        default=os.path.abspath('.'),
                        help='location for temporary build files')
    parser.add_argument('-b',
                        '--batch',
                        action='store_true',
                        help='Run in batch mode')
    parser.add_argument('--which-gfortran',
                        default=which('gfortran'),
                        help='Path to gfortran')
    parser.add_argument('--which-python',
                        default='internal',
                        help='Path to python')
    parser.add_argument('--recipe-dir',
                        default=None,
                        help="location of recipes")

    args = parser.parse_args()

    recipes = args.recipe or RECIPES
    recipe_dir = args.recipe_dir
    if recipe_dir is not None:
        recipe_dir = os.path.abspath(recipe_dir)

    which_gfortran = args.which_gfortran
    if which_gfortran is not None and os.path.isdir(which_gfortran):
        which_gfortran = os.path.join(which_gfortran, 'bin', 'gfortran')

    with cdtemp(dir=args.cache_dir, cleanup=False):
        which_python = args.which_python or which('python')
        if which_python == 'internal':
            which_python = install_internal_python(os.path.abspath('.'),
                                                   batch_mode=args.batch)

        if which_python is None:
            print('Missing Python', file=sys.stderr) and sys.exit(1)
        if which_gfortran is None:
            print('Missing gfortran', file=sys.stderr) and sys.exit(1)

        if recipe_dir is None:
            git_clone_or_update('https://github.com/csdms/csdms-stack',
                                dir='csdms-stack')
            recipe_dir = os.path.abspath(
                os.path.join('csdms-stack', 'conda-recipes'))

        # env = build_env(which_gfortran=which_gfortran,
        #                 which_python=which_python)
        # status('Building with this environment:')
        # for key, val in env.items():
        #     print('{k}={v}'.format(k=blue(key), v=blue(val)), file=sys.stdout)

        with setenv(build_env(which_python=which_python), verbose=True):
            files = conda_build(recipes, dir=recipe_dir, batch_mode=args.batch)

        # status_code = 0
        # files_to_upload = []
        # with cd(recipe_dir):
        #     with homebrew_hidden(prompt=not args.batch):
        #         with setenv(env):
        #             system(['conda', 'clean', '--all'])
        #             for recipe in recipes:
        #                 try:
        #                     system(['conda', 'build', recipe])
        #                 except CalledProcessError:
        #                     status_code = 1
        #                     break
        #                 else:
        #                     files_to_upload.append(conda_build_output(recipe))

        for fname in files:
            success('created: {fname}'.format(fname=fname))

        if len(files) > 0 and prompt('ok to upload to Anaconda cloud',
                                     batch_mode=args.batch):
            for fname in conda_upload(files):
                success('uploaded: {fname}'.format(fname=fname))

            # for fname in files_to_upload:
            #     try:
            #         system(['anaconda', 'upload', '--force', '--channel', 'nightly',
            #                 '--user', 'csdms', fname])
            #     except CalledProcessError:
            #         status_code = 1
            #     else:
            #         success('uploaded: {fname}'.format(fname=fname))

    return len(recipes) - len(files)
Exemple #5
0
def main():
    parser = argparse.ArgumentParser(
        description='Build the CSDMS software stack',
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    parser.add_argument('recipe', nargs='*',
                        help='recipes to build')
    parser.add_argument('--cache-dir', default=os.path.abspath('.'),
                        help='location for temporary build files')
    parser.add_argument('-b', '--batch', action='store_true',
                        help='Run in batch mode')
    parser.add_argument('--which-gfortran', default=which('gfortran'),
                        help='Path to gfortran')
    parser.add_argument('--which-python', default='internal', 
                        help='Path to python')
    parser.add_argument('--recipe-dir', default=None,
                        help="location of recipes")

    args = parser.parse_args()

    recipes = args.recipe or RECIPES
    recipe_dir = args.recipe_dir
    if recipe_dir is not None:
        recipe_dir = os.path.abspath(recipe_dir)

    which_gfortran = args.which_gfortran
    if which_gfortran is not None and os.path.isdir(which_gfortran):
        which_gfortran = os.path.join(which_gfortran, 'bin', 'gfortran')

    with cdtemp(dir=args.cache_dir, cleanup=False):
        which_python = args.which_python or which('python')
        if which_python == 'internal':
            which_python = install_internal_python(os.path.abspath('.'),
                                                   batch_mode=args.batch)

        if which_python is None:
            print('Missing Python', file=sys.stderr) and sys.exit(1)
        if which_gfortran is None:
            print('Missing gfortran', file=sys.stderr) and sys.exit(1)

        if recipe_dir is None:
            git_clone_or_update('https://github.com/csdms/csdms-stack',
                                dir='csdms-stack')
            recipe_dir = os.path.abspath(os.path.join('csdms-stack',
                                                      'conda-recipes'))

        # env = build_env(which_gfortran=which_gfortran,
        #                 which_python=which_python)
        # status('Building with this environment:')
        # for key, val in env.items():
        #     print('{k}={v}'.format(k=blue(key), v=blue(val)), file=sys.stdout)

        with setenv(build_env(which_python=which_python), verbose=True):
            files = conda_build(recipes, dir=recipe_dir, batch_mode=args.batch)

        # status_code = 0
        # files_to_upload = []
        # with cd(recipe_dir):
        #     with homebrew_hidden(prompt=not args.batch):
        #         with setenv(env):
        #             system(['conda', 'clean', '--all'])
        #             for recipe in recipes:
        #                 try:
        #                     system(['conda', 'build', recipe])
        #                 except CalledProcessError:
        #                     status_code = 1
        #                     break
        #                 else:
        #                     files_to_upload.append(conda_build_output(recipe))

        for fname in files:
            success('created: {fname}'.format(fname=fname))

        if len(files) > 0 and prompt('ok to upload to Anaconda cloud',
                                     batch_mode=args.batch):
            for fname in conda_upload(files):
                success('uploaded: {fname}'.format(fname=fname))

            # for fname in files_to_upload:
            #     try:
            #         system(['anaconda', 'upload', '--force', '--channel', 'nightly',
            #                 '--user', 'csdms', fname])
            #     except CalledProcessError:
            #         status_code = 1
            #     else:
            #         success('uploaded: {fname}'.format(fname=fname))

    return len(recipes) - len(files)