pypa / pip

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

`pip show` doesn't handle extras (in the requirements or Required-By metadata) #3797

Open anntzer opened 8 years ago

anntzer commented 8 years ago

extras_requires cannot be displayed using pip show

What I've run:

Within a virtualenv:

$ pip --isolated install 'dask[bag]'
# dask itself has no deps; dask[bags] has a few, they get correctly installed
# <... elided>
$ pip show dask

---
Metadata-Version: 2.0
Name: dask
Version: 0.10.0
Summary: Minimal task scheduling abstraction
Home-page: http://github.com/dask/dask/
Author: Matthew Rocklin
Author-email: mrocklin@gmail.com
License: BSD
Location: /tmp/foo/lib/python3.5/site-packages
Requires: 
Classifiers:
$ pip show 'dask[bag]'
# no output, exits with status 1

More generally, an query UI/API for extras would be nice (especially if it doesn't involve installation -- but that also applies to a query UI/API for dependencies).

jaraco commented 5 years ago

In the meantime, you can output a list of extras with importlib_metadata:

>>> import importlib_metadata
>>> importlib_metadata.metadata('xonsh').get_all('Provides-Extra')
['linux', 'mac', 'proctitle', 'ptk', 'pygments', 'win']
>>> importlib_metadata.metadata('xonsh').get_all('Requires-Dist')
["distro; extra == 'linux'", "gnureadline; extra == 'mac'", "setproctitle; extra == 'proctitle'", "prompt-toolkit; extra == 'ptk'", "pygments (>=2.2); extra == 'pygments'", "win-unicode-console; extra == 'win'"]
pradyunsg commented 1 year ago

Adding a cross-reference to https://discuss.python.org/t/provide-information-on-installed-extras-in-package-metadata/15385 and https://github.com/pypa/packaging-problems/issues/215#issuecomment-504569821