Skip to content

pip show ignores environment markers #12165

@wimglenn

Description

@wimglenn

Description

Perhaps the best explanation is to offer an example:

$ pip show opencv-python | grep Requires
Requires: numpy, numpy, numpy, numpy, numpy, numpy

Wow, it really wants numpy! :)

The reason is that environment markers are there:
https://github.com/opencv/opencv-python/blob/43cd7169cb92d96898d59753796678495b95c833/setup.py#L26-L36

Expected behavior

I'm not sure whether they should be deduplicated by pip:

Requires: numpy

Evaluated and merged by pip (in my case for Python-3.11 on macOS):

Requires: numpy >=1.23.5

Or just rendered without evaluation. It's pretty crazy for this distribution (opencv-python==4.8.0.74) but I guess that would be something like:

Requires: numpy (>=1.13.3) ; python_version < "3.7", numpy (>=1.21.0) ; python_version <= "3.9" and platform_system == "Darwin" and platform_machine == "arm64", numpy (>=1.21.2) ; python_version >= "3.10", numpy (>=1.21.4) ; python_version >= "3.10" and platform_system == "Darwin", numpy (>=1.23.5) ; python_version >= "3.11", numpy (>=1.19.3) ; python_version >= "3.6" and platform_system == "Linux" and platform_machine == "aarch64", numpy (>=1.17.0) ; python_version >= "3.7", numpy (>=1.17.3) ; python_version >= "3.8", numpy (>=1.19.3) ; python_version >= "3.9"

The latter is probably my preference, even though this particular package makes it look pathological. The current behavior of stripping the markers entirely in pip show's output seems worse than any of these options.

pip version

23.2

Python version

3.11

OS

macOS

How to Reproduce

pip install opencv-python
pip show opencv-python

Output

No response

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: needs triageIssues/PRs that need to be triagedtype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions