检查要求是否最新 [英] Check if requirements are up to date

查看:70
本文介绍了检查要求是否最新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pip 要求文件保留我的依赖项列表.

I'm using pip requirements files for keeping my dependency list.

我还尝试遵循最佳实践来管理依赖项,并在需求文件中提供精确的软件包版本.例如:

I also try to follow best practices for managing dependencies and provide precise package versions inside the requirements file. For example:

Django==1.5.1
lxml==3.0

问题是:是否有办法告诉requirements.txt内列出的软件包,Python软件包索引中有可用的较新软件包版本?

The question is: Is there a way to tell that there are any newer package versions available in the Python Package Index for packages listed inside requirements.txt?

对于此特定示例,当前最新的可用版本分别是Django和lxml的1.6.2和3.3.4.

For this particular example, currently latest available versions are 1.6.2 and 3.3.4 for Django and lxml respectively.

我已经尝试过pip install --upgrade -r requirements.txt,但是它说所有信息都是最新的:

I've tried pip install --upgrade -r requirements.txt, but it says that all is up-to-date:

$ pip install --upgrade -r requirements.txt 
Requirement already up-to-date: Django==1.5.1 ...

请注意,此时我不想运行实际的升级-我只想查看是否有可用的更新.

Note that at this point I don't want to run an actual upgrade - I just want to see if there are any updates available.

推荐答案

Pip内置了此功能.假设您在virtualenv类型内:

Pip has this functionality built-in. Assuming that you're inside your virtualenv type:

$ pip list --outdated
psycopg2 (Current: 2.5.1 Latest: 2.5.2)
requests (Current: 2.2.0 Latest: 2.2.1)

$ pip install -U psycopg2 requests

之后,将下载并安装新版本的psycopg2和请求.然后:

After that new versions of psycopg2 and requests will be downloaded and installed. Then:

$ pip freeze > requirements.txt

您已完成.这不是一个命令,但是优点是您不需要任何外部依赖项.

And you are done. This is not one command but the advantage is that you don't need any external dependencies.

这篇关于检查要求是否最新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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