'Module dependency graph in Python 3

How do I graph module dependencies in Python 3? I found snakefood, but it seems to only work with Python 2.



Solution 1:[1]

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:

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 ShoeLace