检查要求是否是最新的

Check if requirements are up to date(检查要求是否是最新的)
本文介绍了检查要求是否是最新的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 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

问题是:有没有办法告诉 Python 包索引中是否有任何更新的包版本可用于 requirements.txt 中列出的包?

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.

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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I make a list of all members in a discord server using discord.py?(如何使用 discord.py 列出不和谐服务器中的所有成员?)
how to change discord.py bot activity(如何更改 discord.py 机器人活动)
Issues with getting VoiceChannel.members and Guild.members to return a full list(让 VoiceChannel.members 和 Guild.members 返回完整列表的问题)
Add button components to a message (discord.py)(将按钮组件添加到消息(discord.py))
on_message() and @bot.command issue(on_message() 和@bot.command 问题)
How to edit a message in discord.py(如何在 discord.py 中编辑消息)