在将pip升级到pip 10.x.x之后解析需求文件的正确方法? [英] Proper way to parse requirements file after pip upgrade to pip 10.x.x?
问题描述
所以今天我确实发现,随着pip 10.x.x
的发布,req
软件包更改了目录,现在可以在pip._internal.req
下找到.
由于通常的做法是在setup.py
中使用parse_requirements
函数从需求文件中安装所有依赖项,所以现在我想知道这种做法是否应该更改,因为它现在位于_internal
下?>
或者不使用parse_requirements
的最佳实践是什么?
我想出了正确的方法是在setup.py中添加依赖项,例如:
REQUIRED_PACKAGES = [
'boto3==1.7.33'
]
if __name__ == '__main__':
setup(
...
install_requires=REQUIRED_PACKAGES,
...
)
,而您的requirements.txt
中只有一个.
.如果从文件中安装,它将自动从setup.py
安装所有软件包.
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
.
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
?
Or what is actually best practice without using parse_requirements
?
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,
...
)
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屋!