pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.55k stars 3.04k forks source link

pip install still ignores extra-index-url #6799

Closed vsespb closed 5 years ago

vsespb commented 5 years ago

Environment

Description

pip raises 404 after connecting to https://pypi.python.org/simple/ and ignores --extra-index-url option

Expected behavior

after connecting to https://pypi.python.org/simple/ and getting 404, it should go and search for a package on server specified in --extra-index-url option

How to Reproduce

pip3 install myprivatelib --verbose --extra-index-url https://pypi.dev.example.com/simple/

Output

$ pip3 install myprivatelib  --verbose --extra-index-url https://pypi.dev.example.com/simple/
Converted retries value: Retry(total=5, connect=None, read=None, redirect=None) -> Retry(total=Retry(total=5, connect=None, read=None, redirect=None), connect=None, read=None, redirect=None)
Converted retries value: Retry(total=5, connect=None, read=None, redirect=None) -> Retry(total=Retry(total=5, connect=None, read=None, redirect=None), connect=None, read=None, redirect=None)
Collecting myprivatelib
  2 location(s) to search for versions of myprivatelib:
  * https://pypi.python.org/simple/myprivatelib/
  * https://pypi.dev.example.com/simple/myprivatelib/
  Getting page https://pypi.python.org/simple/myprivatelib/
  Looking up "https://pypi.python.org/simple/myprivatelib/" in the cache
  Returning cached "301 Moved Permanently" response (ignoring date and etag information)
  Looking up "https://pypi.org/simple/myprivatelib/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.org
  https://pypi.org:443 "GET /simple/myprivatelib/ HTTP/1.1" 404 13
  Status code 404 not in [200, 203, 300, 301]
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 795, in get_page
    resp.raise_for_status()
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/models.py", line 893, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/myprivatelib/

Also:

Looks like issue https://github.com/pypa/pip/pull/6367 but accoring to https://github.com/pypa/pip/pull/6367#issuecomment-479064440 it's fixed in Debian Stretch

I have version with fix:

 apt-cache policy python3-pip
python3-pip:
  Installed: 9.0.1-2+deb9u1
  Candidate: 9.0.1-2+deb9u1
  Version table:

changedlog https://metadata.ftp-master.debian.org/changelogs//main/p/python-pip/python-pip_9.0.1-2+deb9u1_changelog

python-pip (9.0.1-2+deb9u1) stretch; urgency=medium

  * Team upload.
  * Add Properly_catch_requests_HTTPError_in_index.py.patch, which fixes
    --extra-index-url results in "HTTPError: 404 Client Error: NOT FOUND".
    The patch makes works even with the unbundled requests. (Closes: #837764).
uranusjr commented 5 years ago

Looks like #6373, which fixed a vendoring issue so the exception is correctly caught when pip is packaged “debundled”. I believe the fix has been released as part of 19.1, but never made it into Debian Stretch.

Your choices are probably to either use an alternative Python distribution (instead of Debian’s), or upgrade to Buster.

vsespb commented 5 years ago

Ok, thanks. if it's downstream issue, then you can close this. I just thought it must be fixed in Debian according to this comment https://github.com/pypa/pip/pull/6367#issuecomment-479064440 and changelog I posted in first message.

xavfernandez commented 5 years ago

Closing since it happens on an old pip version and seems linked to Debian unvendoring. If you can reproduce the issue with latest vanilla-pip, feel free to reopen the issue.