Пример #1
0
def load_test_file(test_file, variants):
    """
    Load a given test file.

    Args:
        test_file (str): Path to the test file to load.
    """
    if not os.path.exists(test_file):
        return None

    test_file_data = conda_utils.render_yaml(test_file, variants, permit_undefined_jinja=True, schema=_TEST_FILE_SCHEMA)

    return test_file_data
Пример #2
0
def _validate_config_file(env_file, variants):
    '''Perform some validation on the environment file after loading it.'''
    try:
        meta_obj = conda_utils.render_yaml(env_file,
                                           variants=variants,
                                           schema=_ENV_CONFIG_SCHEMA)
        if not (Key.packages.name in meta_obj.keys()
                or Key.imported_envs.name in meta_obj.keys()):
            raise OpenCEError(Error.CONFIG_CONTENT)
        return meta_obj
    except (Exception, SystemExit) as exc:  #pylint: disable=broad-except
        raise OpenCEError(Error.ERROR,
                          "Error in {}:\n  {}".format(env_file,
                                                      str(exc))) from exc
Пример #3
0
def _get_package_dependencies(path, variant_config_files, variants):
    """
    Return a list of output packages and a list of dependency packages
    for the recipe at a given path. Uses conda-render to determine this information.
    """
    metas = conda_utils.render_yaml(path, variants, variant_config_files)

    # Parse out the package names and dependencies from each variant
    packages = set()
    run_deps = set()
    host_deps = set()
    build_deps = set()
    test_deps = set()
    for meta,_,_ in metas:
        packages.add(meta.meta['package']['name'])
        run_deps.update(meta.meta['requirements'].get('run', []))
        host_deps.update(meta.meta['requirements'].get('host', []))
        build_deps.update(meta.meta['requirements'].get('build', []))
        string = meta.meta['build'].get('string', [])
        if 'test' in meta.meta:
            test_deps.update(meta.meta['test'].get('requires', []))

    return packages, run_deps, host_deps, build_deps, test_deps, string
Пример #4
0
def load_package_config(config_file=None, variants=None):
    '''
    Check for a config file. If the user does not provide a recipe config
    file as an argument, it will be assumed that there is only one
    recipe to build, and it is in the directory called 'recipe'.
    '''
    if not config_file and not os.path.exists(
            utils.DEFAULT_RECIPE_CONFIG_FILE):
        recipe_name = os.path.basename(os.getcwd())
        build_config_data = {
            'recipes': [{
                'name': recipe_name,
                'path': 'recipe'
            }]
        }
    else:
        if not config_file:
            config_file = utils.DEFAULT_RECIPE_CONFIG_FILE
        if not os.path.exists(config_file):
            raise OpenCEError(Error.CONFIG_FILE, config_file)

        build_config_data = conda_utils.render_yaml(config_file, variants)

    return build_config_data, config_file