Python utility to produce a simple graph of the dependencies between functions in a Python module.
This is a simple home-made project, the aim of which is to teach myself how to do this kind of analysis, learn how to package a Python module and enjoy some nice time coding. Note that there are more elaborated projects already existing (see at the end of this README).
Disclaimer: while I try to make this code correct, there is no guarantee that it is bug free. Use at your own risk!
- You can clone the git repository with:
git clone https://github.com/matthieu-bruneaux/pydep.git
- You can then install the module with:
sudo make install
- To remove it, run (from the git repository folder):
sudo make uninstall
or from any folder:
sudo pip uninstall pydep
- You can see the detailed usage instructions with:
pydep -h
- You can produce a
.dot
file (to be processed by thedot
utility fromgraphviz
) from a Python module with:pydep tests/inputFiles/exampleModule.py > deps.dot
- A pdf or png version of the graph can then be obtained with:
dot -Tpdf deps.dot -o deps.pdf # pdf output dot -Tpng deps.dot -o deps.png # png output
Here is an example output:
A Makefile is provided, type make
to get some summary usage information:
Makefile for the pydep Python module Type: "make <target>" where <target> is one of the following: test Run the tests with coverage output doc Run Sphinx to make the docs clean Remove generated doc, tests and pyc files You need sudo rights for the following ones: install Install the module and command-line tools uninstall Uninstall the module
This project uses the ast
built-in module from Python, about which I read
when looking at the snakefood
project.
Those projects are more advanced and mature, that’s probably what you want to get if you need to analyse the dependencies in your project (disclaimer: this is the result of a Google search, I didn’t tested all of those projects myself!). The list is not exhaustive and might miss some interesting projects:
- pydepgraph by Stefano Maggiolo (GitHub repo)
- pydeps by thebjorn
- modulegraph by Ronald Oussoren
- Python call graph by Gerald Kaszuba et al.
- snakefood by Martin Blais
- py2depgraph by Toby Dickenson
A quick search for “pydep” in GitHub might also return interesting hits.