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

"pip show" incorrect result for "Required-by" #6947

Closed
Svetlitski opened this issue Aug 30, 2019 · 1 comment · Fixed by #6957
Closed

"pip show" incorrect result for "Required-by" #6947

Svetlitski opened this issue Aug 30, 2019 · 1 comment · Fixed by #6957
Labels
auto-locked Outdated issues that have been locked by automation C: list/show 'pip list' or 'pip show' good first issue A good item for first time contributors to work on type: bug A confirmed bug or unintended behavior

Comments

@Svetlitski
Copy link

Environment

  • pip version: 19.2.3
  • Python version: 3.7.4
  • OS: macOS Mojave 10.14.6

Description

Running pip show <package> does not display all dependent packages under "Required-by:", even when <package> shows up in the "Requires:" field of a dependent package.

Expected behavior
Running pip show <package> should show all packages dependent on <package> under the "Required-by:" field of the output.

How to Reproduce

virtualenv pip_show_bug
source pip_show_bug/bin/activate
pip install black
pip show click
pip show black

click is clearly a dependency of black, but black does not show up under "Required-by:" when you run pip show click. All of black's other dependencies (i.e. appdirs, attrs, and toml) behave as expected with pip show, and running pip show black does show click under "Required:"

Output

bash-5.0$ virtualenv pip_show_broken
Using base prefix '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/kevin/pip_show_broken/bin/python3.7
Also creating executable in /Users/kevin/pip_show_broken/bin/python
Installing setuptools, pip, wheel...
done.
bash-5.0$ source pip_show_broken/bin/activate
(pip_show_broken) bash-5.0$ pip install black
Collecting black
  Using cached https://files.pythonhosted.org/packages/30/62/cf549544a5fe990bbaeca21e9c419501b2de7a701ab0afb377bc81676600/black-19.3b0-py36-none-any.whl
Collecting appdirs (from black)
  Using cached https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl
Collecting attrs>=18.1.0 (from black)
  Using cached https://files.pythonhosted.org/packages/23/96/d828354fa2dbdf216eaa7b7de0db692f12c234f7ef888cc14980ef40d1d2/attrs-19.1.0-py2.py3-none-any.whl
Collecting toml>=0.9.4 (from black)
  Using cached https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl
Collecting click>=6.5 (from black)
  Using cached https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl
Installing collected packages: appdirs, attrs, toml, click, black
Successfully installed appdirs-1.4.3 attrs-19.1.0 black-19.3b0 click-7.0 toml-0.10.0
(pip_show_broken) bash-5.0$ pip show click
Name: Click
Version: 7.0
Summary: Composable command line interface toolkit
Home-page: https://palletsprojects.com/p/click/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD
Location: /Users/kevin/pip_show_broken/lib/python3.7/site-packages
Requires: 
Required-by: 
(pip_show_broken) bash-5.0$ pip show black
Name: black
Version: 19.3b0
Summary: The uncompromising code formatter.
Home-page: https://github.com/ambv/black
Author: Łukasz Langa
Author-email: lukasz@langa.pl
License: MIT
Location: /Users/kevin/pip_show_broken/lib/python3.7/site-packages
Requires: appdirs, click, toml, attrs
Required-by: 
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Aug 30, 2019
@xavfernandez xavfernandez added C: list/show 'pip list' or 'pip show' type: bug A confirmed bug or unintended behavior labels Aug 30, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Aug 30, 2019
@xavfernandez xavfernandez added the good first issue A good item for first time contributors to work on label Aug 30, 2019
@xavfernandez
Copy link
Member

Thanks for the report, I can reproduce the issue.

The fix should be quite simple:

name = dist.get('name', '')
required_by = [
pkg.project_name for pkg in pkg_resources.working_set
if name in [required.name for required in pkg.requires()]
]

We are comparing the project names without normalisation and Click would require it since it uses a capital C.

>>> [pkg for pkg in pkg_resources.working_set if pkg.project_name == 'Click'][0].project_name
'Click'
>>> [pkg for pkg in pkg_resources.working_set if pkg.project_name == 'black'][0].requires()
[Requirement.parse('click>=6.5'), Requirement.parse('attrs>=18.1.0'), Requirement.parse('appdirs'), Requirement.parse('toml>=0.9.4')]

For the contributors interested in fixing it, canonicalize_name would be the function to use.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 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 C: list/show 'pip list' or 'pip show' good first issue A good item for first time contributors to work on type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants