简体   繁体   中英

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).

Could please someone explain to me what exactly is going on?

Thanks!

Pip version: 6.0.6 Python: 2.6 Distro: Centos 6.5

Below is pip's log:

pip -vvv install 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:

# 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:

>>> 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.
It was fixed in version 7.1.1 of pip and is probably described in the following entry in the release notes:

Normalize post-release spellings for rev/r prefixes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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