Repository: pypa/pip

Issue:
Indicate where we are looking for packages
If you frequently edit your ~/.pip/pip.conf to add and remove indexes, then it's easy to forget what state you've left it in and it's useful to be able to see where pip is searching for packages. E.g.:

$ pip install --download=. --find-links=/tmp/wheels 'smlib.web>=3.0'
Collecting smlib.web>=3.0 from ['https://pypi.python.org/simple', '/tmp/wheels']
...
No matching distribution found for smlib.web>=3.0 from ['https://pypi.python.org/simple', '/tmp/wheels']

---

_This was automatically migrated from pypa/pip#2790 to reparent it to the `master` branch. Please see original pull request for any previous discussion._

_Original Submitter: @msabramo_



Discussion:
Any interest in this?

No change since June, should it be closed ?


Resolving patch:
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -27,6 +27,7 @@
     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 @@ def __init__(self, find_links, index_urls, allow_all_prereleases=False,
                     )
                     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
--- a/pip/resolve.py
+++ b/pip/resolve.py
@@ -154,6 +154,11 @@ def resolve(self, requirement_set):
             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


Test patch:
diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py
--- 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):