How do I graph module dependencies in Python 3? I found snakefood, but it seems to only work with Python 2.
-
possible duplicate of [Creating Dependency Graphs in Python](http://stackoverflow.com/questions/4160746/creating-dependency-graphs-in-python) – Cory Kramer May 30 '14 at 20:13
-
@cyber: Unfortunately, I want the module dependencies rather than the call dependencies. – Neil G May 30 '14 at 20:35
-
3I don't understand the close votes… how is this not about programming — specifically "software tools commonly used by programmers"? – Neil G May 30 '14 at 20:36
-
Did you find any dependency graph for Python3? I'm unable to build `snakefood` even with the fixes Terry suggested (missing bin folder) – Motti Oct 03 '19 at 08:51
-
@Motti No! Please let me know if you find something. – Neil G Oct 03 '19 at 08:57
-
1Oh well, it's only been 5 years. – Motti Oct 03 '19 at 09:40
-
1@motti See my answer. – Neil G Jun 16 '20 at 19:28
3 Answers
-
This would be more useful if there was any documentation whatsoever on how to use your package :) – Martin Cejp Dec 23 '22 at 10:14
-
@MartinCejp Thanks. Feel free to contribute to `README.rst` :) You just run it with your project directory as the sole argument and it spits out a diagram. – Neil G Dec 23 '22 at 10:49
I presume you are talking about this snakefood, available on PyPI, though not not updated there since 2009. Since it is an application intended to be run, rather than just a library of modules intended to be imported, you can execute it with Python 2.7 even if the target is a directory of Python 3 modules. It could be run from either 2.x or 3.x with subprocess. Its output files can be read equally well with any Python.
I cloned it with hg clone --insecure <src> <dest>
. My preliminary experiments indicate that very little change would be needed to run it with 3.x. I just needed the following in 2 of the 4 biggest files to get them to compile.
print x
=>print(x)
except XError, e:
=>except XError as e:

- 18,414
- 3
- 40
- 52
-
returns "invalid syntax" if run on a directory of python3 modules – Erik Aronesty May 28 '20 at 21:38
-
3@ErikAronesty It could well be that changes from 2014 to 2020 invalidated what I said then. Better to use a more up-to-date program as suggested by Neil G's answer. – Terry Jan Reedy Jun 17 '20 at 16:58
python3 dependency graphs generator
https://github.com/Trim21/snakefood3
I had the same question 3 years ago, so I forked snakefood and fixed it for Python 3.