version.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:globus-cli 作者: globus 项目源码 文件源码
def get_versions():
    """
    Wrap in a function to ensure that we don't run this every time a CLI
    command runs (yuck!)

    Also protects import of `requests` from issues when grabbed by setuptools.
    More on that inline
    """
    # import in the func (rather than top-level scope) so that at setup time,
    # `requests` isn't required -- otherwise, setuptools will fail to run
    # because requests isn't installed yet.
    import requests
    try:
        version_data = requests.get(
            "https://pypi.python.org/pypi/globus-cli/json").json()
        latest = max(LooseVersion(v) for v in version_data["releases"])
        return latest, LooseVersion(__version__)
    # if the fetch from pypi fails
    except requests.RequestException:
        return None, LooseVersion(__version__)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号