[Community] Dependency graphing

Kai Hänninen kai.hanninen at mbconcert.fi
Sat Mar 25 14:47:20 EET 2006


Hi guys,

I was playing with some nice scripts today from

  http://www.tarind.com/depgraph.html

which make it easy to generate graphs of dependencies in python modules. 
Naturally I was interested to see how our projects -- PCL, ZCO and 
PrimaGIS -- would look like when turned into such graphs.

There's a sample of a graph generated for cartography.data.postgis module at

  http://void.technocore.fi/~dokai/cartography-data-postgis.py.png

to get an idea what they look like.

If you'd like to generate the graphs for yourself, download the 
following scripts from the depgraph website:

  http://www.tarind.com/py2depgraph.py

  http://www.tarind.com/depgraph2dot.py

and install graphviz (http://www.research.att.com/sw/tools/graphviz/) 
unless you have it already.

Now you can use the following (all in one line) shell command to 
generate the graphs for our projects.


   for f in $(find $SRCPATH -name '*.py'); do python2.4 py2depgraph.py 
$f | python2.4 depgraph2dot.py | dot -T png -o $(echo $f|sed s#$(echo 
$SRCPATH|sed s'#\(.*\)/\(.*\)#\1#')/##|sed 's#/#-#g').png; done


Before running the above one-liner you must set the SRCPATH environment 
variable to let it know which files to generate the graphs for. I used 
something like

# PCL
export SRCPATH=/usr/lib/python2.4/site-packages/cartography

# ZCO
export SRCPATH=/usr/local/zope3.2/instance/lib/python/zco

# PrimaGIS
export SRCPATH=/usr/local/zope3.2/instance/lib/python/zco

which you should modify to match your system. Make sure there is no 
trailing slash at the end of the path. It may take a while to generate 
the graphs.

I didn't anylyze the graphs in detail yet, but it is nice to confirm 
that zope.interface is a fairly isolated and small addition to PCL and 
definitely not the monster that a full Zope system is. Just compare 
plain sizes of the graphs for PCL and ZCO/PrimaGIS to see what I mean.

cheers,
Kai



-- 
Kai Hänninen                  +358-50-558-7935
Software engineer             www.mbconcert.fi
MB Concert Ky                 kai.hanninen at mbconcert.fi



More information about the Community mailing list