From 8a89487d42f9f0cd3058d8f130bb6dbd3011aa71 Mon Sep 17 00:00:00 2001 From: Blazej Floch Date: Wed, 12 Jul 2017 14:23:57 -0400 Subject: [PATCH] Implements #442 - Adds build_requires and private_build_requires options to rez-depends --- src/rez/cli/depends.py | 10 +++++++++- src/rez/package_search.py | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/rez/cli/depends.py b/src/rez/cli/depends.py index 6767580e2..887d7af6f 100644 --- a/src/rez/cli/depends.py +++ b/src/rez/cli/depends.py @@ -10,6 +10,12 @@ def setup_parser(parser, completions=False): parser.add_argument( "--paths", type=str, default=None, help="set package search path") + parser.add_argument( + "-b", "--build-requires", action="store_true", default=False, + help="Include build_requires") + parser.add_argument( + "-p", "--private-build-requires", action="store_true", default=False, + help="Include private_build_requires") parser.add_argument( "-g", "--graph", action="store_true", help="display the dependency tree as an image") @@ -51,7 +57,9 @@ def command(opts, parser, extra_arg_groups=None): pkgs_list, g = get_reverse_dependency_tree( package_name=opts.PKG, depth=opts.depth, - paths=pkg_paths) + 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) diff --git a/src/rez/package_search.py b/src/rez/package_search.py index eb5c827f9..373c93a6a 100644 --- a/src/rez/package_search.py +++ b/src/rez/package_search.py @@ -15,7 +15,9 @@ from rez.utils.formatting import PackageRequest -def get_reverse_dependency_tree(package_name, depth=None, paths=None): +def get_reverse_dependency_tree(package_name, depth=None, paths=None, + build_requires=False, + private_build_requires=False): """Find packages that depend on the given package. This is a reverse dependency lookup. A tree is constructed, showing what @@ -60,7 +62,15 @@ def get_reverse_dependency_tree(package_name, depth=None, paths=None): continue pkg = max(packages, key=lambda x: x.version) - requires = set(pkg.requires or []) + requires = [] + if not build_requires and not private_build_requires: + requires = pkg.requires or [] + else: + for variant in pkg.iter_variants(): + requires += variant.get_requires(build_requires, private_build_requires) + + requires = set(requires) + for req_list in (pkg.variants or []): requires.update(req_list)