Permalink
Browse files

Merge pull request #695 from agronholm/develop

Append / to the PyPI URL to reduce unnecessary redirects
  • Loading branch information...
2 parents 60e181b + 47af6d4 commit 6e02c6e0bfd7da42771484157eb1edea5db8aa13 @qwcode qwcode committed Oct 2, 2012
Showing with 11 additions and 10 deletions.
  1. +11 −10 pip/index.py
View
@@ -101,12 +101,22 @@ def sort_path(path):
return files, urls
def find_requirement(self, req, upgrade):
+ def mkurl_pypi_url(url):
+ loc = posixpath.join(url, url_name)
+ # For maximum compatibility with easy_install, ensure the path
+ # ends in a trailing slash. Although this isn't in the spec
+ # (and PyPI can handle it without the slash) some other index
+ # implementations might break if they relied on easy_install's behavior.
+ if not loc.endswith('/'):
+ loc = loc + '/'
+ return loc
+
url_name = req.url_name
# Only check main index if index URL is given:
main_index_url = None
if self.index_urls:
# Check that we have the url_name correctly spelled:
- main_index_url = Link(posixpath.join(self.index_urls[0], url_name))
+ main_index_url = Link(mkurl_pypi_url(self.index_urls[0]))
# This will also cache the page, so it's okay that we get it again later:
page = self._get_page(main_index_url, req)
if page is None:
@@ -116,15 +126,6 @@ def find_requirement(self, req, upgrade):
# adding more index URLs from requirements files
all_index_urls = self.index_urls + self.mirror_urls
- def mkurl_pypi_url(url):
- loc = posixpath.join(url, url_name)
- # For maximum compatibility with easy_install, ensure the path
- # ends in a trailing slash. Although this isn't in the spec
- # (and PyPI can handle it without the slash) some other index
- # implementations might break if they relied on easy_install's behavior.
- if not loc.endswith('/'):
- loc = loc + '/'
- return loc
if url_name is not None:
locations = [
mkurl_pypi_url(url)

0 comments on commit 6e02c6e

Please sign in to comment.