Repository: pypa/pip

Issue:
Package epochs not being honored
`pip 6.0.7`

Specifically having issue with the [foursquare](https://pypi.python.org/pypi/foursquare) package.

```
$ pip install foursquare -d . -v
Collecting foursquare
  Getting page https://pypi.python.org/simple/foursquare/
  Starting new HTTPS connection (1): pypi.python.org
  "GET /simple/foursquare/ HTTP/1.1" 200 997
  URLs to search for versions for foursquare:
  * https://pypi.python.org/simple/foursquare/
  Getting page https://pypi.python.org/simple/foursquare/
  Analyzing links from page https://pypi.python.org/simple/foursquare/
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-1%212015.2.1.tar.gz#md5=328ca7286d49864da39629950dcac26e (from https://pypi.python.org/simple/foursquare/), version: 1
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20120418.tar.gz#md5=1d5ef2fccde05d84c7dc612f106b9bd8 (from https://pypi.python.org/simple/foursquare/), version: 20120418
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20120429.tar.gz#md5=f5bd955d24fafa00b65b18c65f811c26 (from https://pypi.python.org/simple/foursquare/), version: 20120429
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20120430.tar.gz#md5=681626986a6118af72e74285ee2b5f47 (from https://pypi.python.org/simple/foursquare/), version: 20120430
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20120608.tar.gz#md5=ae562f2b7defca967e21ba2130d53271 (from https://pypi.python.org/simple/foursquare/), version: 20120608
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20120716.tar.gz#md5=4cb485f3ad489e89dba5e44f2c7075df (from https://pypi.python.org/simple/foursquare/), version: 20120716
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2013.07.30.tar.gz#md5=8b70c47d3917829d74b8bdb8ef871e87 (from https://pypi.python.org/simple/foursquare/), version: 2013.07.30
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2013.11.11.tar.gz#md5=abdce97c4528f6e36827a4a1a881c7e2 (from https://pypi.python.org/simple/foursquare/), version: 2013.11.11
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2013.11.12.tar.gz#md5=4234ed32f4617690f4965a680cffc27b (from https://pypi.python.org/simple/foursquare/), version: 2013.11.12
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2013.11.13.tar.gz#md5=2530d6322bd969a1dde2c92a296bd547 (from https://pypi.python.org/simple/foursquare/), version: 2013.11.13
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2013.12.10.tar.gz#md5=e08ce724a8c43e41b65163989a4660c3 (from https://pypi.python.org/simple/foursquare/), version: 2013.12.10
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2013.12.17.tar.gz#md5=a1302f75e5a0cc8b769776908fef0ccf (from https://pypi.python.org/simple/foursquare/), version: 2013.12.17
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20130131.tar.gz#md5=ec4260d459df0cd6931d1957af641ae3 (from https://pypi.python.org/simple/foursquare/), version: 20130131
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20130212.tar.gz#md5=b92011db77f4d53ddb4023da2ff86908 (from https://pypi.python.org/simple/foursquare/), version: 20130212
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20130402.tar.gz#md5=162bbc21203e9527e552e1694d596b6e (from https://pypi.python.org/simple/foursquare/), version: 20130402
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20130626.tar.gz#md5=4e6f10a0c5f40e94ce6bc036d3fd30a1 (from https://pypi.python.org/simple/foursquare/), version: 20130626
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20130702.tar.gz#md5=d9a4023a7ee1718f14bd62a103a76232 (from https://pypi.python.org/simple/foursquare/), version: 20130702
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-20130707.tar.gz#md5=80d4c753161672a69160dd36d77c93eb (from https://pypi.python.org/simple/foursquare/), version: 20130707
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2014.01.18.tar.gz#md5=eb62df7a8ab7f9efdbbf3fe14302bccb (from https://pypi.python.org/simple/foursquare/), version: 2014.01.18
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2014.04.02.tar.gz#md5=8bfd89e8e12d13c0310656fd5c6e94e6 (from https://pypi.python.org/simple/foursquare/), version: 2014.04.02
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2014.04.10.tar.gz#md5=26e3d9713dafe172fcddf5e1ac64bcec (from https://pypi.python.org/simple/foursquare/), version: 2014.04.10
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2014.04.15.tar.gz#md5=d1a0bb1b0a14dbd114ff7d9667914f2c (from https://pypi.python.org/simple/foursquare/), version: 2014.04.15
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2014.04.23.tar.gz#md5=9aa64965a9c18d3db965f5c74b03a441 (from https://pypi.python.org/simple/foursquare/), version: 2014.04.23
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2014.04.23a.tar.gz#md5=9140322da142d22fba8a5baf0bec341f (from https://pypi.python.org/simple/foursquare/), version: 2014.04.23a
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2015.2.1.tar.gz#md5=2d5e8c02eed32b4d98c431cbec11edfe (from https://pypi.python.org/simple/foursquare/), version: 2015.2.1
    Found link https://pypi.python.org/packages/source/f/foursquare/foursquare-2015.2.2.tar.gz#md5=adf3cdd96c0fa0945761ca64e1c1584b (from https://pypi.python.org/simple/foursquare/), version: 2015.2.2
    Skipping link http://github.com/mLewisLogic/foursquare (from https://pypi.python.org/simple/foursquare/); not a file
  Using version 20130707 (newest of versions: 20130707, 20130702, 20130626, 20130402, 20130212, 20130131, 20120716, 20120608, 20120430, 20120429, 20120418, 2015.2.2, 2015.2.1, 2014.4.23, 2014.4.15, 2014.4.10, 2014.4.2, 2014.1.18, 2013.12.17, 2013.12.10, 2013.11.13, 2013.11.12, 2013.11.11, 2013.7.30, 1)
```

You'll notice that it's interpreting the version "1!2015.2.1" as "1".

The parsing code itself seems to be working:

``` python
>>> from pip._vendor.packaging.version import parse
>>> parse('1!2015.2.1')._key
(1, (2015, 2, 1), Infinity, -Infinity, Infinity, -Infinity)
```

Not sure where it's going wrong.



Discussion:
cc @dstufft 

Hmm, that's odd. The packaging library absolutely supports this. I bet it's a regex somewhere that needs updated. Let me test.

I see what it is, it's because PyPI is encoding the `!` as `%21`.


Resolving patch:
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -1114,7 +1114,7 @@ def netloc(self):
 
     @property
     def path(self):
-        return urllib_parse.urlsplit(self.url)[2]
+        return urllib_parse.unquote(urllib_parse.urlsplit(self.url)[2])
 
     def splitext(self):
         return splitext(posixpath.basename(self.path.rstrip('/')))


Test patch: