mirror of https://github.com/pypa/pip
extract _get_indexes_locations logic
This commit is contained in:
parent
39c24740d8
commit
dfe7b253a5
27
pip/index.py
27
pip/index.py
|
@ -291,7 +291,10 @@ class PackageFinder(object):
|
||||||
RemovedInPip7Warning,
|
RemovedInPip7Warning,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _find_all_versions(self, req):
|
def _get_indexes_locations(self, req):
|
||||||
|
"""Returns locations found via self.index_urls
|
||||||
|
with the url_name checked on the main index
|
||||||
|
"""
|
||||||
|
|
||||||
def mkurl_pypi_url(url):
|
def mkurl_pypi_url(url):
|
||||||
loc = posixpath.join(url, url_name)
|
loc = posixpath.join(url, url_name)
|
||||||
|
@ -306,10 +309,10 @@ class PackageFinder(object):
|
||||||
|
|
||||||
url_name = req.url_name
|
url_name = req.url_name
|
||||||
|
|
||||||
# Only check main index if index URL is given:
|
|
||||||
main_index_url = None
|
|
||||||
if self.index_urls:
|
if self.index_urls:
|
||||||
# Check that we have the url_name correctly spelled:
|
# Check that we have the url_name correctly spelled:
|
||||||
|
|
||||||
|
# Only check main index if index URL is given
|
||||||
main_index_url = Link(
|
main_index_url = Link(
|
||||||
mkurl_pypi_url(self.index_urls[0]),
|
mkurl_pypi_url(self.index_urls[0]),
|
||||||
trusted=True,
|
trusted=True,
|
||||||
|
@ -330,13 +333,16 @@ class PackageFinder(object):
|
||||||
) or req.url_name
|
) or req.url_name
|
||||||
|
|
||||||
if url_name is not None:
|
if url_name is not None:
|
||||||
locations = [
|
return [mkurl_pypi_url(url) for url in self.index_urls]
|
||||||
mkurl_pypi_url(url)
|
return []
|
||||||
for url in self.index_urls] + self.find_links
|
|
||||||
else:
|
def _find_all_versions(self, req):
|
||||||
locations = list(self.find_links)
|
index_locations = self._get_indexes_locations(req)
|
||||||
|
file_locations, url_locations = self._sort_locations(index_locations)
|
||||||
|
fl_file_loc, fl_url_loc = self._sort_locations(self.find_links)
|
||||||
|
file_locations.extend(fl_file_loc)
|
||||||
|
url_locations.extend(fl_url_loc)
|
||||||
|
|
||||||
file_locations, url_locations = self._sort_locations(locations)
|
|
||||||
_flocations, _ulocations = self._sort_locations(self.dependency_links)
|
_flocations, _ulocations = self._sort_locations(self.dependency_links)
|
||||||
file_locations.extend(_flocations)
|
file_locations.extend(_flocations)
|
||||||
|
|
||||||
|
@ -357,6 +363,7 @@ class PackageFinder(object):
|
||||||
[Link(url, '-f', trusted=True) for url in self.find_links],
|
[Link(url, '-f', trusted=True) for url in self.find_links],
|
||||||
req.name.lower()
|
req.name.lower()
|
||||||
))
|
))
|
||||||
|
|
||||||
page_versions = []
|
page_versions = []
|
||||||
for page in self._get_pages(locations, req):
|
for page in self._get_pages(locations, req):
|
||||||
logger.debug('Analyzing links from page %s', page.url)
|
logger.debug('Analyzing links from page %s', page.url)
|
||||||
|
@ -364,6 +371,7 @@ class PackageFinder(object):
|
||||||
page_versions.extend(
|
page_versions.extend(
|
||||||
self._package_versions(page.links, req.name.lower())
|
self._package_versions(page.links, req.name.lower())
|
||||||
)
|
)
|
||||||
|
|
||||||
dependency_versions = list(self._package_versions(
|
dependency_versions = list(self._package_versions(
|
||||||
[Link(url) for url in self.dependency_links], req.name.lower()))
|
[Link(url) for url in self.dependency_links], req.name.lower()))
|
||||||
if dependency_versions:
|
if dependency_versions:
|
||||||
|
@ -373,6 +381,7 @@ class PackageFinder(object):
|
||||||
version.location.url for version in dependency_versions
|
version.location.url for version in dependency_versions
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
file_versions = list(
|
file_versions = list(
|
||||||
self._package_versions(
|
self._package_versions(
|
||||||
[Link(url) for url in file_locations],
|
[Link(url) for url in file_locations],
|
||||||
|
|
Loading…
Reference in New Issue