Skip to content

Requires-Python version is not checked before downloading dependencies #11142

@RafaelWO

Description

@RafaelWO

Description

I have a setup.py file for a custom package with python_requires='>=3.6, <3.9' and some dependencies in install_requires.

When I use an environment with Python 3.9 and run pip install -e ., all dependencies are downloaded prior to the Python version check, and the result of an (expected) error due to the Python version mismatch (see how to reproduce.

This was already reported in #9925, fixed in #9994, and released with v21.4. But it's not working as intended for me.

Expected behavior

I would expect the installation process to fail right after the metadata is collected and the Python version mismatch is detected.

pip version

22.1.1

Python version

3.9.12

OS

Ubuntu 20.04.4 LTS

How to Reproduce

  1. Download the following dummy package (my_package.zip) that requires a Python version <3.9
    # tree output
    /home/my_package via 🐍 v3.9.12 via 🅒 py9 
    ❯ tree
    .
    ├── my_package
    │   └── main.py
    └── setup.py
    
  2. Install the package in an environment with Python 3.9 via pip: pip install -e .
  3. You will see that all dependencies are downloaded despite the version mismatch.

Output

Obtaining file:///home/my_package
  Preparing metadata (setup.py) ... done
Collecting requests
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 63.1/63.1 kB 1.5 MB/s eta 0:00:00
Collecting requests_cache<=0.5.2
  Downloading requests_cache-0.5.2-py2.py3-none-any.whl (22 kB)
Collecting pandas
  Downloading pandas-1.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.7/11.7 MB 2.6 MB/s eta 0:00:00
Collecting numpy
  Downloading numpy-1.22.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.8/16.8 MB 4.4 MB/s eta 0:00:00
ERROR: Package 'my-package' requires a different Python: 3.9.12 not in '<3.9,>=3.6'

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions