19

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

Neil G
  • 32,138
  • 39
  • 156
  • 257

3 Answers3

11

I built a tool based on pydeps here.

Neil G
  • 32,138
  • 39
  • 156
  • 257
  • 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
9

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:
Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
4

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.

ShoeLace
  • 3,476
  • 2
  • 30
  • 44
Trim21
  • 41
  • 1
  • 3