예제 #1
0
def decide_what_to_build(recipes_path, python, packages, numpy):
    """Figure out which packages need to be built

    Parameters
    ----------
    recipes_path : str
        Path to folder containg conda recipes
    python : list
        List of python versions to build
    packages : list
        List of packages that already exist on the anaconda channel we are
        interested in
    numpy : list
        List of numpy versions to build.

    Returns
    -------
    metas_to_build : list
        the metadata for the conda build with three extra fields:
            - full_build_path
            - build_name
            - build_command
    metas_not_to_build : list
        Same as `packages_to_build`
    """

    metas_not_to_build = []
    metas_to_build = []

    # remove hash string for comparison
    packages_tmp = list(packages)
    packages_no_hash = [remove_hash_string(name) for name in packages_tmp]
    pkgs_dict = group_packages(packages_no_hash)

    # logger.info("Build Plan")
    # logger.info("Determining package build names...")
    # logger.info('{: <8} | {}'.format('to build', 'built package name'))
    recipes_path = os.path.abspath(recipes_path)
    logger.info("recipes_path = {}".format(recipes_path))
    for folder in sorted(os.listdir(recipes_path)):
        print(f'\n{"="*80}\n{os.path.basename(recipes_path)}\n{"="*80}\n')
        recipe_dir = os.path.join(recipes_path, folder)
        if os.path.isfile(recipe_dir):
            # Add support for single-package builds:
            if folder == 'meta.yaml':
                recipe_dir = recipes_path
            else:
                continue
        if 'meta.yaml' not in os.listdir(recipe_dir):
            continue
        logger.debug('Evaluating recipe: {}'.format(recipe_dir))
        build, run, test = get_deps_from_metadata(recipe_dir)
        # only need to do multiple numpy builds if the meta.yaml pins the numpy
        # version in build and run.
        numpy_build_versions = numpy
        if 'numpy x.x' not in build:
            numpy_build_versions = [DEFAULT_NP_VER]
        python_build_versions = python
        if 'python' not in set(build + run):
            python_build_versions = [DEFAULT_PY]
        for py, npy in itertools.product(python_build_versions,
                                         numpy_build_versions):
            logger.debug("Checking py={} and npy={}".format(py, npy))
            try:
                with env_var('CONDA_NPY', npy):
                    path_to_built_package, build_cmd = determine_build_name(
                        recipe_dir, '--python', py, '--numpy', npy)
            except RuntimeError as re:
                logger.error(re)
                continue
            if '.tar.bz' not in path_to_built_package:
                on_anaconda_channel = True
                name_on_anaconda = "Skipping {}".format(folder, py, npy)
            else:
                name_on_anaconda = os.sep.join(
                    path_to_built_package.split(os.sep)[-2:])

                # choose which package to build without hash name
                name_no_hashstring = remove_hash_string(name_on_anaconda)

                # pdb.set_trace()
                #on_anaconda_channel = name_on_anaconda in packages
                #on_anaconda_channel = name_no_hashstring in packages_no_hash

                # quick way to search packages
                on_anaconda_channel = False
                simple_name = get_simplified_name(name_no_hashstring)
                if simple_name in pkgs_dict:
                    if name_no_hashstring in pkgs_dict[simple_name]:
                        on_anaconda_channel = True

                meta = MetaData(recipe_dir)
                meta.full_build_path = path_to_built_package
                meta.build_name = name_on_anaconda
                meta.build_command = build_cmd
                if on_anaconda_channel:
                    metas_not_to_build.append(meta)
                else:
                    metas_to_build.append(meta)

            logger.info('{:<8} | {:<5} | {:<5} | {}'.format(
                str(not bool(on_anaconda_channel)), py, npy, name_on_anaconda))

    return metas_to_build, metas_not_to_build
예제 #2
0
def decide_what_to_build(recipes_path, python, packages, numpy):
    """Figure out which packages need to be built

    Parameters
    ----------
    recipes_path : str
        Path to folder containg conda recipes
    python : list
        List of python versions to build
    packages : list
        List of packages that already exist on the anaconda channel we are
        interested in
    numpy : list
        List of numpy versions to build.

    Returns
    -------
    metas_to_build : list
        the metadata for the conda build with three extra fields:
            - full_build_path
            - build_name
            - build_command
    metas_not_to_build : list
        Same as `packages_to_build`
    """

    metas_not_to_build = []
    metas_to_build = []
    # logger.info("Build Plan")
    # logger.info("Determining package build names...")
    # logger.info('{: <8} | {}'.format('to build', 'built package name'))
    recipes_path = os.path.abspath(recipes_path)
    logger.info("recipes_path = {}".format(recipes_path))
    if 'meta.yaml' in os.listdir(recipes_path):
        folders = [recipes_path]
    else:
        folders = sorted(os.listdir(recipes_path))
    logger.info("\nFiguring out which recipes need to build...")
    for folder in folders:
        recipe_dir = os.path.join(recipes_path, folder)
        if os.path.isfile(recipe_dir):
            continue
        if 'meta.yaml' not in os.listdir(recipe_dir):
            continue
        logger.debug('Evaluating recipe: {}'.format(recipe_dir))
        build, run, test = get_deps_from_metadata(recipe_dir)
        # only need to do multiple numpy builds if the meta.yaml pins the numpy
        # version in build and run.
        numpy_build_versions = numpy
        if 'numpy x.x' not in build:
            numpy_build_versions = [DEFAULT_NP_VER]
        python_build_versions = python
        if 'python' not in set(build + run):
            python_build_versions = [DEFAULT_PY]
        for py, npy in itertools.product(python_build_versions,
                                         numpy_build_versions):
            logger.debug("Checking py={} and npy={}".format(py, npy))
            try:
                with env_var('CONDA_NPY', npy):
                    path_to_built_package, build_cmd = determine_build_name(
                        recipe_dir, '--python', py, '--numpy', npy)
            except RuntimeError as re:
                logger.error(re)
                continue
            if '.tar.bz' not in path_to_built_package:
                on_anaconda_channel = True
                name_on_anaconda = "Skipping {}".format(folder, py, npy)
            else:
                name_on_anaconda = os.sep.join(
                    path_to_built_package.split(os.sep)[-2:])
                # pdb.set_trace()
                meta = MetaData(recipe_dir)
                on_anaconda_channel = name_on_anaconda in packages
                meta.full_build_path = path_to_built_package
                meta.build_name = name_on_anaconda
                meta.build_command = build_cmd
                if on_anaconda_channel:
                    metas_not_to_build.append(meta)
                else:
                    metas_to_build.append(meta)

            logger.info('{:<8} | {:<5} | {:<5} | {}'.format(
                str(not bool(on_anaconda_channel)), py, npy, name_on_anaconda))

    return metas_to_build, metas_not_to_build
예제 #3
0
def decide_what_to_build(recipes_path, python, packages, numpy):
    """Figure out which packages need to be built

    Parameters
    ----------
    recipes_path : str
        Path to folder containg conda recipes
    python : list
        List of python versions to build
    packages : list
        List of packages that already exist on the anaconda channel we are
        interested in
    numpy : list
        List of numpy versions to build.

    Returns
    -------
    metas_to_build : list
        the metadata for the conda build with three extra fields:
            - full_build_path
            - build_name
            - build_command
    metas_not_to_build : list
        Same as `packages_to_build`
    """

    metas_not_to_build = []
    metas_to_build = []
    # logger.info("Build Plan")
    # logger.info("Determining package build names...")
    # logger.info('{: <8} | {}'.format('to build', 'built package name'))
    recipes_path = os.path.abspath(recipes_path)
    logger.info("recipes_path = {}".format(recipes_path))
    for folder in sorted(os.listdir(recipes_path)):
        recipe_dir = os.path.join(recipes_path, folder)
        if os.path.isfile(recipe_dir):
            continue
        if 'meta.yaml' not in os.listdir(recipe_dir):
            continue
        logger.debug('Evaluating recipe: {}'.format(recipe_dir))
        build, run, test = get_deps_from_metadata(recipe_dir)
        # only need to do multiple numpy builds if the meta.yaml pins the numpy
        # version in build and run.
        numpy_build_versions = numpy
        if 'numpy x.x' not in build:
            numpy_build_versions = [DEFAULT_NP_VER]
        python_build_versions = python
        if 'python' not in set(build + run):
            python_build_versions = [DEFAULT_PY]
        for py, npy in itertools.product(python_build_versions,
                                         numpy_build_versions):
            logger.debug("Checking py={} and npy={}".format(py, npy))
            try:
                with env_var('CONDA_NPY', npy):
                    path_to_built_package, build_cmd = determine_build_name(
                        recipe_dir, '--python', py, '--numpy', npy)
            except RuntimeError as re:
                logger.error(re)
                continue
            if '.tar.bz' not in path_to_built_package:
                on_anaconda_channel = True
                name_on_anaconda = "Skipping {}".format(
                    folder, py, npy
                )
            else:
                name_on_anaconda = os.sep.join(
                    path_to_built_package.split(os.sep)[-2:])
                # pdb.set_trace()
                meta = MetaData(recipe_dir)
                on_anaconda_channel = name_on_anaconda in packages
                meta.full_build_path = path_to_built_package
                meta.build_name = name_on_anaconda
                meta.build_command = build_cmd
                if on_anaconda_channel:
                    metas_not_to_build.append(meta)
                else:
                    metas_to_build.append(meta)

            logger.info('{:<8} | {:<5} | {:<5} | {}'.format(
                str(not bool(on_anaconda_channel)), py, npy, name_on_anaconda))

    return metas_to_build, metas_not_to_build