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

how do I tell what extras are available? #2718

Closed
glyph opened this issue Apr 24, 2015 · 9 comments
Closed

how do I tell what extras are available? #2718

glyph opened this issue Apr 24, 2015 · 9 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@glyph
Copy link

glyph commented Apr 24, 2015

I know I can pip install requests[security], but how do I know it's called "security" (other than reading the docs) and how do I know there aren't other things I also want to install? Can pip do this for me? Is there a tool outside of pip I should be using?

@rbtcollins
Copy link

Today the only way to know is to examine the metadata. This is static for wheels, and dynamic for everything else. I think it could be reasonable for pip to have a query mode to answer questions like this.

@dholth
Copy link
Member

dholth commented Apr 24, 2015

pkg_resources has an easy way to get at this information. Shown is how you would look at metadata for ipython on sys.path, but it is also possible to load metadata from any directory e.g. an uninstalled package:

>>> import pkg_resources
>>> pkg_resources.working_set.by_key['ipython'].extras
['all', 'doc', 'notebook', 'nbconvert', 'qtconsole', 'test', 'zmq', 'parallel']

>>> pkg_resources.working_set.by_key['ipython']._dep_map
{None: [],
 'all': [Requirement.parse('pyzmq>=2.1.11'),
  Requirement.parse('nose>=0.10.1'),
  Requirement.parse('tornado>=3.1'),
  Requirement.parse('Sphinx>=1.1'),
  Requirement.parse('pygments'),
  Requirement.parse('numpydoc'),
  Requirement.parse('Sphinx>=0.3'),
  Requirement.parse('jinja2')],
 'doc': [Requirement.parse('numpydoc'), Requirement.parse('Sphinx>=1.1')],
 'nbconvert': [Requirement.parse('jinja2'),
  Requirement.parse('pygments'),
  Requirement.parse('Sphinx>=0.3')],
 'notebook': [Requirement.parse('jinja2'),
  Requirement.parse('pyzmq>=2.1.11'),
  Requirement.parse('tornado>=3.1')],
 'parallel': [Requirement.parse('pyzmq>=2.1.11')],
 'qtconsole': [Requirement.parse('pyzmq>=2.1.11'),
  Requirement.parse('pygments')],
 'test': [Requirement.parse('nose>=0.10.1'), Requirement.parse('mock')],
 'zmq': [Requirement.parse('pyzmq>=2.1.11')]}

In wheels, there is a *.dist-info directory with METADATA. It has one Provides-Extra: line for each extra:

Provides-Extra: docs
Provides-Extra: testing

In *.egg-info, there is a requires.txt. This package has a [test] extra.

setuptools
pytz

[test]
python-dateutil

@glyph
Copy link
Author

glyph commented Apr 24, 2015

@dholth - there are not enough scare quotes in the world to put around “easy” in that first sentence :)

@rbtcollins
Copy link

@dholth I was assuming the request was for uninstalled packages :)

@dstufft
Copy link
Member

dstufft commented Mar 22, 2017

Closing this, use pypi/warehouse#1855 instead.

@dstufft dstufft closed this as completed Mar 22, 2017
@rbtcollins
Copy link

What about packages that aren't on warehouse? e.g. direct url references etc...

@dstufft
Copy link
Member

dstufft commented Mar 23, 2017

@rbtcollins I'm not sure what you'd want pip to do in those cases? A command that downloads it and just prints out what extras are available?

@rbtcollins
Copy link

exactly

@dstufft
Copy link
Member

dstufft commented Mar 24, 2017

Ok, we can keep this, but I'm going to fold it into #484.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 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
Projects
None yet
Development

No branches or pull requests

4 participants