コード例 #1
0
def validate_build_tree(tree, external_deps, start_nodes=None):
    '''
    Check a build tree for dependency compatability.
    '''
    packages = [
        package
        for recipe in build_tree.traverse_build_commands(tree, start_nodes)
        for package in recipe.packages
    ]
    channels = {
        channel
        for recipe in build_tree.traverse_build_commands(tree, start_nodes)
        for channel in recipe.channels
    }
    env_channels = {
        channel
        for node in tree.nodes() for channel in node.channels
    }
    deps = build_tree.get_installable_packages(tree, external_deps,
                                               start_nodes, True)

    pkg_args = " ".join([
        "\"{}\"".format(utils.generalize_version(dep)) for dep in deps
        if not utils.remove_version(dep) in packages
    ])
    channel_args = " ".join({
        "-c \"{}\"".format(channel)
        for channel in channels.union(env_channels)
    })

    cli = "conda create --dry-run -n test_conda_dependencies {} {}".format(
        channel_args, pkg_args)
    ret_code, std_out, std_err = utils.run_command_capture(cli)
    if not ret_code:
        raise OpenCEError(Error.VALIDATE_BUILD_TREE, cli, std_out, std_err)
コード例 #2
0
def validate_build_tree(tree, external_deps, start_nodes=None):
    '''
    Check a build tree for dependency compatability.
    '''
    # Importing BuildTree is intentionally done here because it checks for the
    # existence of conda-build as BuildTree uses conda_build APIs.
    from open_ce import build_tree  # pylint: disable=import-outside-toplevel

    packages = [package for recipe in build_tree.traverse_build_commands(tree, start_nodes)
                            for package in recipe.packages]
    channels = {channel for recipe in build_tree.traverse_build_commands(tree, start_nodes) for channel in recipe.channels}
    env_channels = {channel for node in tree.nodes() for channel in node.channels}
    deps = build_tree.get_installable_packages(tree, external_deps, start_nodes, True)

    pkg_args = " ".join(["\"{}\"".format(utils.generalize_version(dep)) for dep in deps
                                                                    if not utils.remove_version(dep) in packages])
    channel_args = " ".join({"-c \"{}\"".format(channel) for channel in channels.union(env_channels)})

    cli = "conda create --dry-run -n test_conda_dependencies {} {}".format(channel_args, pkg_args)
    ret_code, std_out, std_err = utils.run_command_capture(cli)
    if not ret_code:
        raise OpenCEError(Error.VALIDATE_BUILD_TREE, cli, std_out, std_err)
コード例 #3
0
def test_get_dependency_names():
    '''
    Tests that the dependency names can be retrieved for each item in a BuildTree
    '''
    mock_build_tree = TestBuildTree([], "3.6", "cpu", "openmpi", "10.2")
    mock_build_tree._tree = sample_build_commands()

    output = ""
    for node in build_tree.traverse_build_commands(mock_build_tree._tree,
                                                   return_node=True):
        output += ' '.join(
            dep.build_command.name()
            for dep in mock_build_tree._tree.successors(node)) + "\n"

    expected_output = "\nrecipe2-py2-6-cpu-openmpi-10-2\nrecipe2-py2-6-cpu-openmpi-10-2 recipe3\n"

    assert output == expected_output