如何从 setup.py 文件中读取需求
How to read the requirements from a setup.py file
我正在为 Python 移动应用程序 Pythonista 制作实用程序。它基本上只是 pip 的一个版本,默认情况下不支持它(是的,我知道已经存在,我正在为个人使用做不同的事情)。
在包中,存在 setup.py,但并不总是存在 requirements.txt。如何读取文件并从中找到依赖项?或者,我将如何获取依赖项?我知道这应该是可能的,因为 pip 本身会找到依赖项,而且它们并不总是有 requirements.txt.
那么我如何通过 setup.py 或 pip 获取包的依赖项呢?
不使用 setup.py 或 pip 的解决方案:
你可以试试我们pipreqs package。
pipreqs - Generate requirements.txt file for any project based on imports
另一个选项使用 pip-tools
The pip-compile command lets you compile a requirements.txt file from your dependencies, specified in either setup.py or requirements.in.
我正在为 Python 移动应用程序 Pythonista 制作实用程序。它基本上只是 pip 的一个版本,默认情况下不支持它(是的,我知道已经存在,我正在为个人使用做不同的事情)。
在包中,存在 setup.py,但并不总是存在 requirements.txt。如何读取文件并从中找到依赖项?或者,我将如何获取依赖项?我知道这应该是可能的,因为 pip 本身会找到依赖项,而且它们并不总是有 requirements.txt.
那么我如何通过 setup.py 或 pip 获取包的依赖项呢?
不使用 setup.py 或 pip 的解决方案:
你可以试试我们pipreqs package。
pipreqs - Generate requirements.txt file for any project based on imports
另一个选项使用 pip-tools
The pip-compile command lets you compile a requirements.txt file from your dependencies, specified in either setup.py or requirements.in.