Python 设置工具的依赖项自动发现?

Dependencies auto discovery for Python setuptools?

在使用 setuptools 打包 Python 应用程序时,我正在使用我的应用程序的所有 PyPI 依赖项填充 install_requires 列表。我发现自己手动梳理所有资源以找到这些。这是正确的方法吗?或者可以以某种方式自动填充此列表?

在我看来install_requires应该只列出你项目的直接依赖(不是间接的,你的依赖的依赖)。所以它通常是一个相对较短的列表,可能应该手工策划,就像你开始时仔细挑选你的图书馆一样。

在常见情况下,如果某些 导入 无法解析,使用 tox in combination with a linting tool such as pylint 会让您知道,这很可能意味着 [=10] 中缺少库=].

如果您已经有很多依赖项但忘记了哪些依赖项并且没有使 install_requires 保持最新,那么我相信诸如 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, ) 之类的工具。