1 [[!template id=gitrepo repo=depgraph]]
3 This set of scripts scans a Python file for module dependencies, and
4 generates code for [Graphviz dot][graphviz]. See [[call_graph]] for a
5 script that generates dependency graphs *within* a module.
7 Originally by Toby Dickenson, the scripts are good for giving you the
8 "long view" on how your project is organized. I've altered the
11 My [py2depgraph.py][] also prints out path information for each
12 module, so that you can show or hide module nodes based on those
13 paths. For example, ignoring system modules to focus on your
16 My [depgraph2dot.py][] has an added method
17 `depgraph2dot.invalidpath(module_name, path)` that you can override to
18 determine the paths you like.
20 I've also added the `depgraph2dot` methods
22 * `is_Cext(module_name, path)`,
23 * `Cext_depends(module_name, path)`,
24 * `Cext_edge_attributes(module_name, Cext_name)`,
25 * `Cext_node_attributes(Cext_name)`, and
26 * `Cext_depcolor(Cext_name)`
28 to detect and configure the shared C libraries extending Python, so
29 you know where to look for the code your Python depends on.
31 [[!template id=gitrepo repo=unfold_protein]]
33 As example, here is the depgraph of my protein unfolding program `unfold.py`
35 $ python py2depgraph.py unfold.py | python depgraph2dot.py | dot -T png -o depgraph.png
37 with standard python modules in orange,
38 python packages in hash-based colors,
39 and C extension modules in light blue.
40 Again, these are only the files containing either `wking` or `comedi`
43 [[!img depgraph.png class="scaled"
44 alt="unfold.py dependency graph"
45 title="unfold.py dependency graph"]]
47 [graphviz]: http://www.graphviz.org
48 [originals]: http://tarind.com/depgraph.html
50 http://git.tremily.us/?p=depgraph.git;a=blob_plain;f=py2depgraph.py;hb=HEAD
52 http://git.tremily.us/?p=depgraph.git;a=blob_plain;f=depgraph2dot.py;hb=HEAD
54 [[!tag tags/programming]]