Dependencies auto discovery for Python setuptools?

这一生的挚爱 提交于 2020-06-17 03:56:27

问题


In packaging a Python application using setuptools, I am populating the install_requires list with all the PyPI dependencies of my application. I find myself manually combing through all my sources to find these. Is this the right way to do it? Or can this list be auto-populated somehow?


回答1:


From my point of view install_requires should only list the direct dependencies of your project (not the indirect ones, the dependencies of your dependencies). So it often is a relatively short list, that can probably should be curated by hand, the same way you carefully hand-picked your libraries to begin with.

In common scenarios, using tox in combination with a linting tool such as pylint would let you know if some imports can't be resolved, which most likely means that libraries are missing from install_requires.

In the case you already have lots of dependencies but lost track of which ones and didn't keep install_requires up to date, then I believe a tool such as pipreqs or pigar can help (there are probably other similar tools, but that's the ones I stumbled upon while browsing the following similar questions: 1, 2).



来源:https://stackoverflow.com/questions/61130177/dependencies-auto-discovery-for-python-setuptools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!