Skip to content

Commit

Permalink
Implements AcademySoftwareFoundation#442 - Adds build_requires and pr…
Browse files Browse the repository at this point in the history
…ivate_build_requires options to rez-depends
  • Loading branch information
Blazej Floch committed Jul 12, 2017
1 parent f70013d commit 8a89487
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/rez/cli/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 12 additions & 2 deletions src/rez/package_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 8a89487

Please sign in to comment.