Alexander Artemenko avatar Alexander Artemenko committed cb93112 Merge

Few my changes to make pip working better with version numbers.

Comments (0)

Files changed (1)

         # 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:
-            url_name = self._find_url_name(Link(self.index_urls[0]), url_name, req)
+            real_url_name = None
+            for index_url in self.index_urls:
+                real_url_name = self._find_url_name(Link(index_url), url_name, req)
+                if real_url_name:
+                    break
+            url_name = real_url_name
         if url_name is not None:
             locations = [
                 posixpath.join(url, url_name)
         else:
             locations = list(self.find_links)
         locations.extend(self.dependency_links)
-        for version in req.absolute_versions:
-            if url_name is not None:
+        if url_name is not None:
+            for version in req.absolute_versions:
                 locations = [
-                    posixpath.join(url, url_name, version)] + locations
+                    posixpath.join(url, url_name, version)
+                    for url in self.index_urls] + locations
         locations = [Link(url) for url in locations]
         logger.debug('URLs to search for versions for %s:' % req)
         for location in locations:
         found_versions.sort(reverse=True)
         applicable_versions = []
         for (parsed_version, link, version) in found_versions:
-            if version not in req.req:
+            if pkg_resources.safe_version(version) not in req.req:
                 logger.info("Ignoring link %s, version %s doesn't match %s"
                             % (link, version, ','.join([''.join(s) for s in req.req.specs])))
                 continue
             if link.scheme in backend.schemes:
                 backend(link).unpack(location)
                 return
-        dir = tempfile.mkdtemp()
+        tmp_dir = tempfile.mkdtemp()
         if link.url.lower().startswith('file:'):
             source = url_to_filename(link.url)
             content_type = mimetypes.guess_type(source)
             if not ext:
                 ext = mimetypes.guess_extension(content_type)
                 filename += ext
-            temp_location = os.path.join(dir, filename)
+            temp_location = os.path.join(tmp_dir, filename)
             fp = open(temp_location, 'wb')
             if md5_hash:
                 download_hash = md5()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.