Display where pip is looking for packages (#4483)

Display where PackageFinder is looking for packages
This commit is contained in:
Pradyun S. Gedam 2017-06-27 02:15:47 +05:30 committed by Paul Moore
parent c92cbe7aba
commit 21be153044
4 changed files with 31 additions and 0 deletions

1
news/4483.feature Normal file
View File

@ -0,0 +1 @@
pip now displays where it is looking for packages, if non-default locations are used.

View File

@ -27,6 +27,7 @@ from pip.exceptions import (
BestVersionAlreadyInstalled, DistributionNotFound, InvalidWheelFilename,
UnsupportedWheel
)
from pip.models import PyPI
from pip.pep425tags import get_supported
from pip.utils import (
ARCHIVE_EXTENSIONS, SUPPORTED_EXTENSIONS, cached_property, normalize_path,
@ -188,6 +189,18 @@ class PackageFinder(object):
)
break
def get_formatted_locations(self):
lines = []
if self.index_urls and self.index_urls != [PyPI.simple_url]:
lines.append(
"Looking in indexes: {}".format(", ".join(self.index_urls))
)
if self.find_links:
lines.append(
"Looking in links: {}".format(", ".join(self.find_links))
)
return "\n".join(lines)
def add_dependency_links(self, links):
# # FIXME: this shouldn't be global list this, it should only
# # apply to requirements of the package that specifies the

View File

@ -154,6 +154,11 @@ class Resolver(object):
any(req.has_hash_options for req in root_reqs)
)
# Display where finder is looking for packages
locations = self.finder.get_formatted_locations()
if locations:
logger.info(locations)
# Actually prepare the files, and collect any exceptions. Most hash
# exceptions cannot be checked ahead of time, because
# req.populate_link() needs to be called before we can make decisions

View File

@ -114,6 +114,10 @@ def test_install_from_pypi(script):
assert egg_info_folder in result.files_created, str(result)
assert initools_folder in result.files_created, str(result)
# Should not display where it's looking for files
assert "Looking in indexes: " not in result.stdout
assert "Looking in links: " not in result.stdout
def test_editable_install(script):
"""
@ -633,6 +637,10 @@ def test_install_package_with_root(script, data):
)
assert root_path in result.files_created, str(result)
# Should show find-links location in output
assert "Looking in indexes: " not in result.stdout
assert "Looking in links: " in result.stdout
def test_install_package_with_prefix(script, data):
"""
@ -809,6 +817,10 @@ def test_url_incorrect_case_file_index(script, data):
egg_folder = script.site_packages / 'Dinner-2.0-py%s.egg-info' % pyversion
assert egg_folder in result.files_created, str(result)
# Should show index-url location in output
assert "Looking in indexes: " in result.stdout
assert "Looking in links: " not in result.stdout
@pytest.mark.network
def test_compiles_pyc(script):