Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of requests exceptions when dependencies are debundled #6111

Closed
wants to merge 1 commit into from
Closed

Fix handling of requests exceptions when dependencies are debundled #6111

wants to merge 1 commit into from

Conversation

yan12125
Copy link
Contributor

@yan12125 yan12125 commented Jan 4, 2019

Apparently Python thinks pip._vendor.requests.exceptions.HTTPError and requests.HTTPError are different classes, causing the following error when querying out-dated packages:

$ PYTHONPATH=./src python -c 'from pip._internal import main; main()' list -o
Exception:
Traceback (most recent call last):
  File "/home/yen/Projects/pip/src/pip/_internal/cli/base_command.py", line 154, in main
    status = self.run(options, args)
  File "/home/yen/Projects/pip/src/pip/_internal/commands/list.py", line 138, in run
    packages = self.get_outdated(packages, options)
  File "/home/yen/Projects/pip/src/pip/_internal/commands/list.py", line 149, in get_outdated
    dist for dist in self.iter_packages_latest_infos(packages, options)
  File "/home/yen/Projects/pip/src/pip/_internal/commands/list.py", line 149, in <listcomp>
    dist for dist in self.iter_packages_latest_infos(packages, options)
  File "/home/yen/Projects/pip/src/pip/_internal/commands/list.py", line 184, in iter_packages_latest_infos
    all_candidates = finder.find_all_candidates(dist.key)
  File "/home/yen/Projects/pip/src/pip/_internal/index.py", line 635, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/home/yen/Projects/pip/src/pip/_internal/index.py", line 782, in _get_pages
    page = _get_html_page(location, session=self.session)
  File "/home/yen/Projects/pip/src/pip/_internal/index.py", line 230, in _get_html_page
    resp = _get_html_response(url, session=session)
  File "/home/yen/Projects/pip/src/pip/_internal/index.py", line 181, in _get_html_response
    resp.raise_for_status()
  File "/usr/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
pip._vendor.requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/ufw/

Steps to reproduce this issue:

  1. Patch setuptools due to another debundling issue
  2. Install a Python package not hosted on PyPI (e.g., ufw)
  3. Enable debundling in pip. I do it by modifying vendor:
diff --git a/src/pip/_vendor/__init__.py b/src/pip/_vendor/__init__.py
index b919b540..76ec847d 100644
--- a/src/pip/_vendor/__init__.py
+++ b/src/pip/_vendor/__init__.py
@@ -14,7 +14,7 @@ import sys
 # Downstream redistributors which have debundled our dependencies should also
 # patch this value to be true. This will trigger the additional patching
 # to cause things like "six" to be available as pip.
-DEBUNDLED = False
+DEBUNDLED = True

 # By default, look in this directory for a bunch of .whl files which we will
 # add to the beginning of sys.path before attempting to import anything. This
@@ -30,6 +30,7 @@ def vendored(modulename):
     vendored_name = "{0}.{1}".format(__name__, modulename)

     try:
+        raise ImportError
         __import__(vendored_name, globals(), locals(), level=0)
     except ImportError:
         try:

@yan12125
Copy link
Contributor Author

yan12125 commented Jan 4, 2019

Try it again and it doesn't work - let me investigate more.

@lock
Copy link

lock bot commented May 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 31, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant