python - 如何在 python 脚本中使用 yolk 来获取特定包的最新版本?

标签 python pip pypi yolk

我想要这样的东西:

yolk.get_lastest_version_number(package_name)

这将返回版本号。

谢谢!

最佳答案

这是一个函数,它将返回包的最新版本号,如果没有这样的包,则返回 None。

from yolk.pypi import CheeseShop

def get_lastest_version_number(package_name):
    pkg, all_versions = CheeseShop().query_versions_pypi(package_name)
    if len(all_versions):
        return all_versions[0]
    return None

>>> get_lastest_version_number('requests')
'2.7.0'
>>> get_lastest_version_number('pip')
'6.1.1'
>>> get_lastest_version_number('django')
'1.8.1'
>>> get_lastest_version_number('Django')    # case insensitive
'1.8.1'
>>> print get_lastest_version_number('dunno')
None

关于python - 如何在 python 脚本中使用 yolk 来获取特定包的最新版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30325479/

相关文章:

Python3 单元测试 : How to compare with MagicMocks Using Operators

python - 导入 tf-sentencepiece 时 undefined symbol

python - 当我的凭证有效时,为什么我不能将我自己的包上传到 PyPI?

python - 如何避免使用 opencv 和 numpy 逐像素循环遍历图像

python - 在Python中, 'a' > 'A'为True的过程和重要性是什么?

python - 错误 : command 'gcc' failed with exit status 1 on CentOS

python - pip 安装选项 "ignore-installed"和 "force-reinstall"之间的区别

python - pip 从私有(private)仓库安装,但来自 PyPi 的要求

python - 一次替换多个正则表达式模式

python - PyInstaller 无法通过 pip 安装