Skip to content

VisualizeDependencies

Mats Wichmann edited this page Feb 27, 2020 · 4 revisions

Analyzing source trees, based on dependency graphs

Tools

While trying to get a deeper understanding for the source of SCons, I actually wanted to see the classes and their dependencies. Googling around I found these two tools that could produce DOT graph files for class or import dependencies from Python source trees:

  • snakefood: Creates module import dependency graphs. Use the Mercurial command hg clone https://hg.furius.ca/public/snakefood for a checkout of the current sources. Note Python 3 support may be incomplete, the project seems rather inactive.
  • pylint: As part of pylint it analyzes class dependencies. Install using pip or distribution package manager.

Commands

Having both applications installed, I called

sfood -i . | sfood-graph > scons_import.dot
pyreverse -p scons -k .

with the SCons source directory as current folder.

Unfortunately, the resulting graphs were pretty large and visualizing them via the dot tool did not help. PNG, PS or SVG output, the images got too large and the layout of the nodes and edges left a lot to desire.

dottoxml.py

Then I remembered the yEd Graph Editor (http://www.yworks.com/en/products_yed_about.html), a great application that can layout and handle even very large datasets...if you find a way to get the data inside. Since it does not import DOT files (yet), I wrote the little converter script dottoxml.py (http://www.mydarc.de/dl9obn/programming/python/dottoxml) that outputs yEd's native file format Graphml (XML).

Now looking at complicated DOT graphs is a snap...have a try!

Examples

The following files were created with the sources for SCons 1.2.0.d20090223 and Waf 1.5.8, they are all available in two versions:

  1. The nodes contain not only the class names, but also methods/attributes ("_fc" suffix) and
  2. class names only (no special suffix). Graphml files (XML) with dependencies that can be read directly by yEd:

Screenshots

SCons classes

Waf classes

SCons packages

Waf packages

Clone this wiki locally