Exemplo n.º 1
0
 def _create_remote_deps(self, dep_graph):
     #pylint: disable=import-outside-toplevel
     from open_ce import conda_utils
     deps = {dep for dep in dep_graph.nodes() if dep.build_command is None}
     seen = set()
     try:
         while deps:
             node = deps.pop()
             for package in node.packages:
                 package_name = utils.remove_version(package)
                 if package_name in seen:
                     continue
                 seen.add(package_name)
                 package_info = conda_utils.get_latest_package_info(self._channels + node.channels, package)
                 dep_graph.add_node(DependencyNode({package}))
                 for dep in package_info['dependencies']:
                     dep_name = utils.remove_version(dep)
                     local_dest = {dest_node for dest_node in dep_graph.nodes()
                                             if dep_name in map(utils.remove_version, dest_node.packages)}
                     if local_dest:
                         dep_graph.add_edge(node, local_dest.pop())
                     else:
                         new_dep = DependencyNode({dep})
                         dep_graph.add_edge(node, new_dep)
                         deps.add(new_dep)
         return dep_graph
     except OpenCEError as err:
         raise OpenCEError(Error.REMOTE_PACKAGE_DEPENDENCIES, deps, err.msg) from err
Exemplo n.º 2
0
def test_search_no_timestamp(mocker):
    from open_ce import conda_utils

    mocker.patch(
        'conda.cli.python_api.run_command',
        side_effect=(
            lambda command, *arguments, **kwargs: conda_search_result()))

    package = "some_package 0.3"
    package_info = conda_utils.get_latest_package_info([], package)

    print("Package Info: ", package_info)
Exemplo n.º 3
0
    def _create_remote_deps(self, dep_graph):
        #pylint: disable=import-outside-toplevel
        from open_ce import conda_utils
        deps = {dep for dep in dep_graph.nodes() if dep.build_command is None}
        seen = set()
        try:
            while deps:
                node = deps.pop()
                ancestor_build_cmds = {
                    x.build_command
                    for x in networkx.ancestors(dep_graph, node)
                    if x.build_command is not None
                }
                channels = []

                ancestor_channels = []
                for cmd in ancestor_build_cmds:
                    ancestor_channels += cmd.channels

                for channel in node.channels + ancestor_channels + self._channels:
                    if not channel in channels:
                        channels += [channel]

                for package in node.packages:
                    package_name = utils.remove_version(package)
                    if package_name in seen:
                        continue
                    seen.add(package_name)
                    # Pass in channels ordered by priority.
                    package_info = conda_utils.get_latest_package_info(
                        channels, package)
                    # package_info is empty for a virtual package.
                    # As of now, this is just one case of package_info being empty.
                    if package_info == "":
                        continue
                    dep_graph.add_node(DependencyNode({package}))
                    for dep in package_info['dependencies']:
                        dep_name = utils.remove_version(dep)
                        local_dest = {
                            dest_node
                            for dest_node in dep_graph.nodes() if dep_name in
                            map(utils.remove_version, dest_node.packages)
                        }
                        if local_dest:
                            dep_graph.add_edge(node, local_dest.pop())
                        else:
                            new_dep = DependencyNode({dep})
                            dep_graph.add_edge(node, new_dep)
                            deps.add(new_dep)
            return dep_graph
        except OpenCEError as err:
            raise OpenCEError(Error.REMOTE_PACKAGE_DEPENDENCIES, deps,
                              err.msg) from err