예제 #1
0
    def run(self):
        if not self.distribution.get_name() == 'UNKNOWN':
            self.run_command('egg_info')
        self.banner("Dependency Graph: note - includes only installed "
                    "packages")

        all_packages = dependency.all_packages(
                           exclusions=self.exclude,
                           include_third_party=self.third_party,
                           exclude_pinned=False)
        if not all_packages:
            log.info("No matching packages to render")
            return


        if self.distribution.get_name() == 'UNKNOWN' and not self.args:
            # Pick any package and set the 'everything' flag if nothing was 
            # specified
            pkg = all_packages.keys()[0]
            self.everything = True
            self.args = [pkg]
            if 'UNKNOWN' in all_packages:
                del all_packages['UNKNOWN']

        roots = []
        if self.args:
            roots = [safe_name(i) for i in self.args]
            for i in roots:
                if not i in all_packages.keys():
                    raise DistutilsOptionError("Unknown package: %s" % i)

        if not roots:
            roots = [self.distribution.get_name()]

        self.banner("Rendering using %s" % self.renderer)

        if self.renderer in ['ascii', 'graphviz']:
            # TODO: use nx digraph as below, retire get_targets
            src, eggs = dependency.get_targets(roots, all_packages,
                                               everything=self.everything,
                                               immediate_deps=True,
                                               follow_all=True,
                                               include_eggs=True,
                                               include_source=True,)

            graph.draw_graph(inclusions=src + eggs, renderer=self.renderer,
                             outfile=self.out)

        else:
            nx_graph, _ = dependency.get_graph_from_ws(working_set)

            if self.renderer == 'd3':
                graph.draw_networkx_with_d3(nx_graph, self.third_party,
                                            self.out)
            elif self.renderer == 'pydot':
                self.fetch_build_eggs(['pydot'])
                graph.draw_networkx_with_pydot(nx_graph, self.third_party,
                                               self.out, self.requirements)
예제 #2
0
    def __init__(self,
                 installer,
                 working_set=None,
                 use_existing=False,
                 draw_graph=False,
                 force_upgrade=False):
        self.installer = installer
        self.use_existing = use_existing
        self.draw_graph = draw_graph
        self.force_upgrade = force_upgrade

        # This is a set of processed requirements.
        self.processed = {}

        # This is the list of stuff we've installed, to hand off to the
        # post-install steps like egg-link etc
        self.new_dists = pkg_resources.WorkingSet([])

        path = installer._path
        destination = installer._dest
        if destination is not None and destination not in path:
            path.insert(0, destination)

        # Make a copy, we don't want to mess up the global w/s if this is
        # what's been passed in.

        # We can't just say WorkingSet(working_set.entries), since ws may
        # contain more paths than distributions (d'oh moment)
        self.ws = pkg_resources.WorkingSet(
            [] if working_set is None else [d.location for d in working_set])

        # First we need to get a map of requirements for what is currently
        # installed. This is so we can play them off against new requirements.

        # For simplicity's sake, we merge all requirements matching installed
        # packages into a single requirement. This also mimics how the
        # packages would have been installed in the first place.

        self.req_graph, self.best = dependency.get_graph_from_ws(self.ws)

        log.debug("Baseline working set: (merged req, dist)")
        for dist, req in self.best.values():
            log.debug("   %25s: %r" % (req, dist))

        if draw_graph:
            graph.draw_networkx_with_pydot(self.req_graph, True)

        # This is our 'baseline' set of packages. Anything we've picked that
        # isn't in here, hasn't yet been fully installed.
        self.env = pkg_resources.Environment(
            [] if force_upgrade or working_set is None else copy.
            copy(working_set.entries))
예제 #3
0
    def run(self):
        if not self.distribution.get_name() == 'UNKNOWN':
            self.run_command('egg_info')
        self.banner("Dependency Graph: note: includes only installed packages")

        all_packages = self._resolve_all_packages()
        roots = self._resolve_roots(all_packages)

        self.banner("Rendering using %s" % self.renderer)

        if self.renderer in ['ascii', 'graphviz']:
            # TODO: use nx digraph as below, retire get_targets
            self._render_ascii(roots, all_packages)
        else:
            import networkx
            g = networkx.DiGraph()
            dependency.get_graph_from_ws(working_set, g)

            if self.what_requires is not None:
                g = self._filter_nodes_leading_to(g, self.what_requires)

            self._render_digraph(g)
예제 #4
0
    def run(self):
        if not self.distribution.get_name() == 'UNKNOWN':
            self.run_command('egg_info')
        self.banner("Dependency Graph: note: includes only installed packages")

        all_packages = self._resolve_all_packages()
        roots = self._resolve_roots(all_packages)

        self.banner("Rendering using %s" % self.renderer)

        if self.renderer in ['ascii', 'graphviz']:
            # TODO: use nx digraph as below, retire get_targets
            self._render_ascii(roots, all_packages)
        else:
            import networkx
            g = networkx.DiGraph()
            dependency.get_graph_from_ws(working_set, g)

            if self.what_requires is not None:
                g = self._filter_nodes_leading_to(g, self.what_requires)

            self._render_digraph(g)
예제 #5
0
    def __init__(self, installer, working_set=None, use_existing=False,
                 draw_graph=False, force_upgrade=False):
        self.installer = installer
        self.use_existing = use_existing
        self.draw_graph = draw_graph
        self.force_upgrade = force_upgrade

        # This is a set of processed requirements.
        self.processed = {}

        # This is the list of stuff we've installed, to hand off to the
        # post-install steps like egg-link etc
        self.new_dists = pkg_resources.WorkingSet([])

        path = installer._path
        destination = installer._dest
        if destination is not None and destination not in path:
            path.insert(0, destination)

        # Make a copy, we don't want to mess up the global w/s if this is
        # what's been passed in.

        # We can't just say WorkingSet(working_set.entries), since ws may
        # contain more paths than distributions (d'oh moment)
        self.ws = pkg_resources.WorkingSet([] if working_set is None else
                                           [d.location for d in working_set])

        # First we need to get a map of requirements for what is currently
        # installed. This is so we can play them off against new requirements.

        # For simplicity's sake, we merge all requirements matching installed
        # packages into a single requirement. This also mimics how the
        # packages would have been installed in the first place.

        self.req_graph, self.best = dependency.get_graph_from_ws(self.ws)

        log.debug("Baseline working set: (merged req, dist)")
        for dist, req in self.best.values():
            log.debug("   %25s: %r" % (req, dist))

        if draw_graph:
            graph.draw_networkx_with_pydot(self.req_graph, True)

        # This is our 'baseline' set of packages. Anything we've picked that
        # isn't in here, hasn't yet been fully installed.
        self.env = pkg_resources.Environment([] if force_upgrade
                                             or working_set is None
                                             else copy.copy(working_set.entries))