def _render_ascii(self, roots, all_packages): tgts = dependency.get_targets(roots, all_packages, everything=self.everything) graph.draw_graph(inclusions=tgts, renderer=self.renderer, outfile=self.out)
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)
def run(self): setuptools._dont_write_bytecode = True if self.distribution.get_name() == 'UNKNOWN' and not self.args: raise DistutilsOptionError('Please specify some packages to ' 'update.') if self.distribution.get_name() != 'UNKNOWN': log.info("Setting dev mode as this has been run from a setup.py " "file") self.dev = True # These are all the packages that could possibly be updated all_packages = (dependency.all_packages (exclusions=self.exclusions, include_third_party=self.third_party)) full_name_list = [i.project_name for i in working_set] log.debug("All: %r" % all_packages.keys()) # These are the root packages to update. If none were passed in, use # this command's distribution. roots = [] if self.args: for i in self.args: if not i in full_name_list: raise DistutilsOptionError("Unknown package: %s" % i) if not i in all_packages: raise DistutilsOptionError("Unable to update package %s, " "it is pinned (See list above)." % i) roots = self.args if not roots: roots = [self.distribution.get_name()] targets = dependency.get_targets(roots, all_packages, everything=self.everything) source_targets = ([i for i in targets if dependency.is_source_package(all_packages[i])] if self.source else []) egg_targets = ([i for i in targets if not dependency.is_source_package(all_packages[i])] if self.eggs else []) # Update as required. if source_targets: self.banner("Source targets") log.info('\n'.join(source_targets)) if egg_targets: self.banner("Egg targets") log.info('\n'.join(egg_targets)) if not egg_targets and not source_targets: log.info("No targets to update") # Check for open files self.check_open_files(egg_targets) # Important Run-Time Order! # 1) update source checkouts and re-create the egg_info dir. This # is very important so the requires.txt is up-to-date [self.update_source(all_packages[i]) for i in source_targets] # 2) Pull in the latest versions of any non-pinned eggs # TODO: During this run, the 'pinned packages' list may actually # change. This is the case when you're updating a prod graph to a dev # graph. It would be nice to figure out these changes before printing # the list of pinned packages earlier, otherwise you have to run the # command twice to get the correct behavior. # Make sure egg targets get done in the right order: self.update_egg_packages(egg_targets) # 3) Re-setup.py develop all the source checkouts. [self.develop_source(all_packages[i]) for i in source_targets] if not self.no_cleanup: self.run_cleanup_in_subprocess()