def _get_packages_which_must_be_changed(paths=None): """Get every Rez package that has dependencies to replace. The user may have provided 1+ packages at once. Each package will be used as the "root" and downstream packages that depend on this package will be searched and returned, here. Args: paths (list[str], optional): The directories to search for Rez package families, Default: :attr:`rez.config.config.packages_path`. Returns: tuple[:class:`rez.packages_.Package`, list, list]: All of the found Rez packages and a list of any Rez package that was considered invalid or any Rez packages that were valid but must be skipped, for some reason. """ packages, invalids, skips = conditional.get_default_latest_packages( paths=paths) downstream = set() for package in _get_user_provided_packages(): downstream_package_names, _ = package_search.get_reverse_dependency_tree( package_name=package.name, depth=1, paths=paths, ) # According to the documenatation in # :func:`rez.package_search.get_reverse_dependency_tree` The # first list always contains `package` by itself. We don't need # this so we discard it here and just get the "depth 1" packages. # downstream_package_names = downstream_package_names[1] downstream.update(downstream_package_names) packages_to_change = [ package for package in packages if package.name in downstream ] return packages_to_change, invalids, skips
def command(opts, parser, extra_arg_groups=None): from rez.package_search import get_reverse_dependency_tree from rez.utils.graph_utils import save_graph, view_graph from rez.config import config from rez.vendor.pygraph.readwrite.dot import write as write_dot import os import os.path config.override("warn_none", True) config.override("show_progress", (not opts.quiet)) if opts.paths is None: pkg_paths = None else: pkg_paths = opts.paths.split(os.pathsep) pkg_paths = [os.path.expanduser(x) for x in pkg_paths if x] pkgs_list, g = get_reverse_dependency_tree( package_name=opts.PKG, depth=opts.depth, paths=pkg_paths, build_requires=opts.build_requires, private_build_requires=opts.private_build_requires) if opts.graph or opts.print_graph or opts.write_graph: gstr = write_dot(g) if opts.print_graph: print(gstr) elif opts.write_graph: save_graph(gstr, dest_file=opts.write_graph) else: view_graph(gstr) return 0 for i, pkgs in enumerate(pkgs_list): if opts.quiet: toks = pkgs else: toks = ["#%d:" % i] + pkgs print(' '.join(toks))
def command(opts, parser, extra_arg_groups=None): from rez.package_search import get_reverse_dependency_tree from rez.utils.graph_utils import save_graph, view_graph from rez.config import config from rez.vendor.pygraph.readwrite.dot import write as write_dot import os import os.path config.override("warn_none", True) config.override("show_progress", (not opts.quiet)) if opts.paths is None: pkg_paths = None else: pkg_paths = opts.paths.split(os.pathsep) pkg_paths = [os.path.expanduser(x) for x in pkg_paths if x] pkgs_list, g = get_reverse_dependency_tree( package_name=opts.PKG, depth=opts.depth, paths=pkg_paths, build_requires=opts.build_requires, private_build_requires=opts.private_build_requires) if opts.graph or opts.print_graph or opts.write_graph: gstr = write_dot(g) if opts.print_graph: print gstr elif opts.write_graph: save_graph(gstr, dest_file=opts.write_graph) else: view_graph(gstr) return 0 for i, pkgs in enumerate(pkgs_list): if opts.quiet: toks = pkgs else: toks = ["#%d:" % i] + pkgs print ' '.join(toks)