简体   繁体   English

Python pip奇怪的软件包版本解析

[英]Python pip weird package version parsing

I'm getting really weird pip behavior while trying to install specific version of configparser package (3.3.0r2). 尝试安装特定版本的configparser软件包(3.3.0r2)时,我得到了非常奇怪的pip行为。

Could please someone explain to me what exactly is going on? 能否请人向我解释到底发生了什么?

Thanks! 谢谢!

Pip version: 6.0.6 Python: 2.6 Distro: Centos 6.5 点子版本:6.0.6 Python:2.6版本:Centos 6.5

Below is pip's log: 以下是pip的日志:

pip -vvv install configparser==3.3.0r2 pip -vvv安装configparser == 3.3.0r2

Collecting configparser==3.3.0r2
  Getting page https://pypi.python.org/simple/configparser/
  URLs to search for versions for configparser==3.3.0r2:
  * https://pypi.python.org/simple/configparser/
  Getting page https://pypi.python.org/simple/configparser/
  Analyzing links from page https://pypi.python.org/simple/configparser/
    Found link https://pypi.python.org/packages/source/c/configparser/configparser-3.2.0r1.tar.gz#md5=49ff19dd5511b069285a293dd3907902 (from https://pypi.python.org/simple/configparser/), version: 3.2.0r1
    Found link https://pypi.python.org/packages/source/c/configparser/configparser-3.2.0r2.tar.gz#md5=ecdc31147658bd9340bcd605c1b7a849 (from https://pypi.python.org/simple/configparser/), version: 3.2.0r2
    Found link https://pypi.python.org/packages/source/c/configparser/configparser-3.2.0r3.tar.gz#md5=8500fd87c61ac0de328fc996fce69b96 (from https://pypi.python.org/simple/configparser/), version: 3.2.0r3
    Found link https://pypi.python.org/packages/source/c/configparser/configparser-3.3.0r1.tar.gz#md5=b6c6a9409be55966a4481f3a729070b3 (from https://pypi.python.org/simple/configparser/), version: 3.3.0r1
    Found link https://pypi.python.org/packages/source/c/configparser/configparser-3.3.0r2.tar.gz#md5=dda0e6a43e9d8767b36d10f1e6770f09 (from https://pypi.python.org/simple/configparser/), version: 3.3.0r2
    Found link https://pypi.python.org/packages/source/c/configparser/configparser-3.5.0b1.tar.gz#md5=d60ca2c714acb4adaf5818c6a1ffd78b (from https://pypi.python.org/simple/configparser/), version: 3.5.0b1
    Found link https://pypi.python.org/packages/source/c/configparser/configparser-3.5.0b2.tar.gz#md5=ad2a71db8bd9a017ed4735eac7acfa07 (from https://pypi.python.org/simple/configparser/), version: 3.5.0b2
  Could not find a version that satisfies the requirement configparser==3.3.0r2 (from versions: 3.2.0.post1, 3.2.0.post2, 3.2.0.post3, 3.3.0.post1, 3.3.0.post2, 3.5.0b1, 3.5.0b2)
  Cleaning up...
  No distributions matching the version for configparser==3.3.0r2
  Exception information:
  Traceback (most recent call last):
    File "/tmp/omnimw/lib/python2.6/site-packages/pip/basecommand.py", line 232, in main
      status = self.run(options, args)
    File "/tmp/omnimw/lib/python2.6/site-packages/pip/commands/install.py", line 339, in run
      requirement_set.prepare_files(finder)
    File "/tmp/omnimw/lib/python2.6/site-packages/pip/req/req_set.py", line 333, in prepare_files
      upgrade=self.upgrade,
    File "/tmp/omnimw/lib/python2.6/site-packages/pip/index.py", line 490, in find_requirement
      'No distributions matching the version for %s' % req
  DistributionNotFound: No distributions matching the version for configparser==3.3.0r2

UPD: Getting even more surprising behaviour, trying to install this package with pip 1.4.1: UPD:尝试使用pip 1.4.1安装此软件包,会得到更多令人惊讶的行为:

# pip install configparser==3.3.0r2

Downloading/unpacking configparser==3.3.0r2
  Could not find a version that satisfies the requirement configparser==**3.3.0r2** (from versions: 3.2.0r1, 3.2.0r2, 3.2.0r3, 3.3.0r1, **3.3.0r2**, 3.5.0b1, 3.5.0b2)
Cleaning up...
No distributions matching the version for configparser==3.3.0r2

The version 3.3.0r2 is normalized (according to PEP 440) to version 3.3.0.post2 which you can check using packaging package yourself: 3.3.0r2版本标准化(根据PEP 440)为3.3.0.post2版本,您可以自己使用打包软件包进行检查:

>>> from packaging.version import Version, parse
>>> parse('3.3.0r2')
<Version('3.3.0.post2')>
>>> Version('3.3.0r2') == Version('3.3.0.post2')
True

From the log it seems that pip normalizes only available versions but not the specified one which later breaks comparison and this is clearly bug in pip. 从日志看来,pip只会规范化可用版本,而不会规范化指定版本,这会破坏比较,这显然是pip中的错误。
It was fixed in version 7.1.1 of pip and is probably described in the following entry in the release notes: 它已在pip版本7.1.1中修复,并且可能在发行说明的以下条目中进行了描述:

Normalize post-release spellings for rev/r prefixes. 将rev / r前缀的发布后拼写标准化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM