Skip to content
Snippets Groups Projects
Commit 76bdc67a authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'fwinkl_20201209T104148' into 'master'

PyUtils: fix for `cmake depends`

See merge request atlas/athena!39006
parents 1bb0ec33 aaf94d1d
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,8 @@ import PyUtils.acmdlib as acmdlib ...@@ -16,6 +16,8 @@ import PyUtils.acmdlib as acmdlib
import argparse import argparse
import pygraphviz import pygraphviz
# Style for python dependencies:
py_style = 'dashed'
def read_package_list(package_file): def read_package_list(package_file):
"""Read packages.txt as a source for the full package path""" """Read packages.txt as a source for the full package path"""
...@@ -100,7 +102,7 @@ def add_legend(graph): ...@@ -100,7 +102,7 @@ def add_legend(graph):
for n in 'abcd': for n in 'abcd':
l.add_node(n, shape='point', style='invis') l.add_node(n, shape='point', style='invis')
l.add_edge('a','b', label='C++', constraint=False) l.add_edge('a','b', label='C++', constraint=False)
l.add_edge('c','d', label='Python', style='dashed', constraint=False) l.add_edge('c','d', label='Python', style=py_style, constraint=False)
class AthGraph: class AthGraph:
...@@ -173,7 +175,7 @@ class AthGraph: ...@@ -173,7 +175,7 @@ class AthGraph:
help='recursively resolve dependencies up to DEPTH (default: unlimited)') help='recursively resolve dependencies up to DEPTH (default: unlimited)')
@acmdlib.argument('--py', action='store_true', @acmdlib.argument('--py', action='store_true',
help='add Python dependencies') help=f'add Python dependencies (marked with ":py" in printout, {py_style} in graph)')
@acmdlib.argument('--regex', action='store_true', @acmdlib.argument('--regex', action='store_true',
help='treat NAME as regular expression') help='treat NAME as regular expression')
...@@ -184,8 +186,8 @@ class AthGraph: ...@@ -184,8 +186,8 @@ class AthGraph:
@acmdlib.argument('-d', '--dot', action='store_true', @acmdlib.argument('-d', '--dot', action='store_true',
help='print DOT graph') help='print DOT graph')
@acmdlib.argument('--noLegend', action='store_true', @acmdlib.argument('--legend', action='store_true',
help='do not add legend to graph') help='add legend to graph')
# Debugging/expert options: # Debugging/expert options:
...@@ -286,17 +288,17 @@ def main(args): ...@@ -286,17 +288,17 @@ def main(args):
g = subgraph(pygraph, pysources, reverse=args.clients, g = subgraph(pygraph, pysources, reverse=args.clients,
maxdepth=args.recursive, nodegetter=lambda n : n.name) maxdepth=args.recursive, nodegetter=lambda n : n.name)
graph.get_subgraph(target).add_edges_from(g.edges(), style='dashed') graph.get_subgraph(target).add_edges_from(g.edges(), style=py_style)
# Change style of nodes that have only Python dependencies: # Change style of nodes that have only Python dependencies:
g = graph.get_subgraph(target) g = graph.get_subgraph(target)
for n in g.nodes_iter(): for n in g.nodes_iter():
if all(e.attr['style']=='dashed' for e in g.edges_iter(n)): if all(e.attr['style']==py_style for e in g.edges_iter(n)):
n.attr['style'] = 'dashed' n.attr['style'] = py_style
# Output final graph: # Output final graph:
if not args.noLegend: if args.dot and args.legend:
add_legend(graph) add_legend(graph)
if args.dot: if args.dot:
...@@ -305,4 +307,5 @@ def main(args): ...@@ -305,4 +307,5 @@ def main(args):
nodes = [e[0] for e in graph.in_edges_iter()] if args.clients \ nodes = [e[0] for e in graph.in_edges_iter()] if args.clients \
else [e[1] for e in graph.out_edges_iter()] else [e[1] for e in graph.out_edges_iter()]
for p in sorted(set(nodes)): for p in sorted(set(nodes)):
print(p) suffix = ':py' if p.attr['style']==py_style else ''
print(f'{p}{suffix}')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment