requirements.txt与setup.py [英] requirements.txt vs setup.py
问题描述
我开始使用Python.我已经在项目中添加了requirements.txt
和setup.py
.但是,我对这两个文件的目的仍然感到困惑.我已经读到setup.py
是为可重新分发的事物而设计的,而requirements.txt
是为非重新分发的事物而设计的.但是我不确定这是正确的.
这两个文件是如何真正使用的?
requirements.txt
这有助于您设置开发环境.诸如pip
之类的程序可用于一次安装文件中列出的所有软件包.之后,您可以开始开发python脚本.如果您计划让其他人参与开发或使用虚拟环境,则特别有用.
这是您的用法:
pip install -r requirements.txt
setup.py
这使您可以创建可以重新分发的软件包.该脚本旨在将软件包安装在最终用户的系统上,而不是像pip install -r requirements.txt
那样准备开发环境.
有关setup.py的更多详细信息,请参见此答案.
两个文件中都列出了项目的依赖项.
I started working with Python. I've added requirements.txt
and setup.py
to my project. But, I am still confused about the purpose of both files. I have read that setup.py
is designed for redistributable things and that requirements.txt
is designed for non-redistributable things. But I am not certain this is accurate.
How are those two files truly intended to be used?
requirements.txt
This helps you to set up your development environment. Programs like pip
can be used to install all packages listed in the file in one fell swoop. After that you can start developing your python script. Especially useful if you plan to have others contribute to the development or use virtual environments.
This is how you use it:
pip install -r requirements.txt
setup.py
This allows you to create packages that you can redistribute. This script is meant to install your package on the end user's system, not to prepare the development environment as pip install -r requirements.txt
does.
See this answer for more details on setup.py.
The dependencies of your project are listed in both files.
这篇关于requirements.txt与setup.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!