Dependency graph for components in a Python package

Is there a way to determine which components in a Python package are dependent on each other? Or at least generate some kind of diagram or graph that shows how all the components in a package are related to each other? For a class in a Python package, I would like to pull out the code for that class and the code that the class depends on too. I can go through all the code in the package and figure it out but it would be a lot quicker if there was some kind of analysis tool that does this.

It looks like the pydeps project builds graphviz graphs of this. I just tried it out – a little fiddly, but I got it to work.

It’s sort of fun just to poke at projects this way. Maybe it will be useful for the kind of refactoring you’re doing; I hope so! I might try it myself.

1 Like

Thanks for the suggestion. I’ll give it a try. Here’s the GitHub link for pydeps