Skip to content

pip download --python-version fails when downloaded package doesn't support the Python version running pip #5369

@mwilliamson

Description

@mwilliamson
  • Pip version: 10.0.1
  • Python version: 2.7
  • Operating system: Linux (Debian)

Description:

I'm using pip download to download packages for a different version of Python than the version that pip is running on. Specifically, I'm using pip on Python 2.7 to download packages for Python 3.5. The wheel for Python 3.5 is downloaded successfully, but pip download exits with an error since the wheel specifies a minimum Python version of 3.4.

Setting ignore_requires_python=True in pip/_internal/commands/download.py turns the error into a warning (which still isn't ideal), but would the proper fix be for check_requires_python to consider the Python version passed to the download command?

What I've run:

$ pip download python-rapidjson --dest . --no-deps --platform manylinux1_x86_64 --python-version 35 --implementation cp --abi cp35m
Collecting python-rapidjson
  File was already downloaded /tmp/py/python_rapidjson-0.5.2-cp35-cp35m-manylinux1_x86_64.whl
python-rapidjson requires Python '>=3.4' but the running Python is 2.7.9

With verbose output, the last part of the output is:

  Downloading from URL https://files.pythonhosted.org/packages/44/59/70b5060b7a5afaec36cdb618dd1c59a389642e739a49b76fef81446f18f8/python_rapidjson-0.5.2-cp35-cp35m-manylinux1_x86_64.whl#sha256=d20ca8dfd9db296941c1f978231ddf9402494c868ae8d6e431b59c8406063cad (from https://pypi.org/simple/python-rapidjson/)
  Saved ./python_rapidjson-0.5.2-cp35-cp35m-manylinux1_x86_64.whl
python-rapidjson requires Python '>=3.4' but the running Python is 2.7.9
Exception information:
Traceback (most recent call last):
  File "/home/michael/apps/virtualenv/local/lib/python2.7/site-packages/pip/_internal/basecommand.py", line 228, in main
    status = self.run(options, args)
  File "/home/michael/apps/virtualenv/local/lib/python2.7/site-packages/pip/_internal/commands/download.py", line 221, in run
    resolver.resolve(requirement_set)
  File "/home/michael/apps/virtualenv/local/lib/python2.7/site-packages/pip/_internal/resolve.py", line 103, in resolve
    self._resolve_one(requirement_set, req)
  File "/home/michael/apps/virtualenv/local/lib/python2.7/site-packages/pip/_internal/resolve.py", line 262, in _resolve_one
    check_dist_requires_python(dist)
  File "/home/michael/apps/virtualenv/local/lib/python2.7/site-packages/pip/_internal/utils/packaging.py", line 55, in check_dist_requires_python
    '.'.join(map(str, sys.version_info[:3])),)
UnsupportedPythonVersion: python-rapidjson requires Python '>=3.4' but the running Python is 2.7.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: downloadAbout fetching data from PyPI and other sourcesauto-lockedOutdated issues that have been locked by automationtype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions