summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPradyun S. Gedam <pradyunsg@users.noreply.github.com>2017-06-27 02:15:47 +0530
committerPaul Moore <p.f.moore@gmail.com>2017-06-26 21:45:47 +0100
commit21be153044a7aa245e12ce3f86793e9b17201519 (patch)
treedc4dd2bb4ff625bfddc6c5ede118da98c0f074a3
parentc92cbe7aba54564141d0f4b26a44fa840fbf14a0 (diff)
downloadpip-21be153044a7aa245e12ce3f86793e9b17201519.tar.gz
Display where pip is looking for packages (#4483)
Display where PackageFinder is looking for packages
-rw-r--r--news/4483.feature1
-rw-r--r--pip/index.py13
-rw-r--r--pip/resolve.py5
-rw-r--r--tests/functional/test_install.py12
4 files changed, 31 insertions, 0 deletions
diff --git a/news/4483.feature b/news/4483.feature
new file mode 100644
index 000000000..51ff98f7a
--- /dev/null
+++ b/news/4483.feature
@@ -0,0 +1 @@
+pip now displays where it is looking for packages, if non-default locations are used.
diff --git a/pip/index.py b/pip/index.py
index 65d98992a..5808b921a 100644
--- a/pip/index.py
+++ b/pip/index.py
@@ -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
diff --git a/pip/resolve.py b/pip/resolve.py
index 517d7b160..e0f8c17c8 100644
--- a/pip/resolve.py
+++ b/pip/resolve.py
@@ -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
diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py
index 2ee4bc21e..033ad3dc8 100644
--- a/tests/functional/test_install.py
+++ b/tests/functional/test_install.py
@@ -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):