Is there a good dependency analysis tool for Pytho

2019-01-08 07:24发布

Dependency analysis programs help us organize code by controlling the dependencies between modules in our code. When one module is a circular dependency of another module, it is a clue to find a way to turn that into a unidirectional dependency or merge two modules into one module.

What is the best dependency analysis tool for Python code?

4条回答
Rolldiameter
2楼-- · 2019-01-08 08:05

I recommend using snakefood for creating graphical dependency graphs of Python projects. It detects dependencies nicely enough to immediately see areas for refactorisation. Its usage is pretty straightforward if you read a little bit of documentation.

Of course, you can omit the graph-creation step and receive a dependency dictionary in a file instead.

查看更多
forever°为你锁心
3楼-- · 2019-01-08 08:06

I don't know what is the best dependency analysis tool. You could look into modulefinder – it's a module in the standard library that determines the set of modules imported by a script.

Of course, with python you have problems of conditional imports, and even potentially scripts calling __import__ directly, so it may not find everything. This is why tools like py2exe need special help to cope with packages like PIL.

查看更多
你好瞎i
4楼-- · 2019-01-08 08:19

I'm not sure about the best tool, but dependency analysis is best done using extracting and scanning the python files of the project.

Here is one such tool using the above technique : orkohunter.net/depends

查看更多
家丑人穷心不美
5楼-- · 2019-01-08 08:25

PyStructure – Automated Structure and Dependency Analysis of Python Code

This is used for PyDev's refactoring features. http://pystructure.ifs.hsr.ch/trac/

查看更多
登录 后发表回答