pip升级到pip 10.x.x后解析需求文件的正确方法? [英] Proper way to parse requirements file after pip upgrade to pip 10.x.x?
问题描述
所以今天我确实发现随着 pip 10.xx
的发布,req
包改变了它的目录,现在可以在 pip._internal 下找到.req
.
So today I did found out that with the release of pip 10.x.x
the req
package changed its directory and can now be found under pip._internal.req
.
由于在 setup.py
中使用 parse_requirements
函数来安装需求文件中的所有依赖项是一种常见的做法,我现在想知道这种做法是否应该改变因为它现在位于 _internal
之下?
Since it is common practice to use the parse_requirements
function in your setup.py
to install all the dependencies out of a requirements file I now wonder if this practice should change since it is now lying under _internal
?
或者不使用 parse_requirements
的实际最佳实践是什么?
Or what is actually best practice without using parse_requirements
?
推荐答案
我想出的正确方法是在 setup.py 中添加依赖项,例如:
What I figured out the right way to do is adding the dependencies in the setup.py like:
REQUIRED_PACKAGES = [
'boto3==1.7.33'
]
if __name__ == '__main__':
setup(
...
install_requires=REQUIRED_PACKAGES,
...
)
并且在您的 requirements.txt
中有一个 .
.如果您从文件安装,它将自动安装 setup.py
中的所有包.
and just have a .
in your requirements.txt
. It will then automatically install all packages from the setup.py
if you install from the file.
这篇关于pip升级到pip 10.x.x后解析需求文件的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!