在将pip升级到pip 10.x.x之后解析需求文件的正确方法? [英] Proper way to parse requirements file after pip upgrade to pip 10.x.x?

查看:83
本文介绍了在将pip升级到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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆