`pip install` with all extras

Viewed 2838

How does one pip install with all extras? I'm aware that doing something like:

pip install -e .[docs,tests,others]

is an option. But, is it possible to do something like:

pip install -e .[all]

This question is similar to setup.py/setup.cfg install all extras. However, the answer there requires that the setup.cfg file be edited. Is it possible to do it without modifying setup.py or setup.cfg?

2 Answers

Is it possible to [install all extras] without modifying setup.py or setup.cfg?

No until the author of the package declares all extras in setup.py. Something like

docs = […]
tests = […]
others = […]
all = docs + tests + others

setup(
    …,
    extras_require = {
        'all': all,
        'docs': docs,
        'tests': tests,
        'others': others,
    },
    …,
)

I do it this way:

import itertools

extras_require = {
   'foo': [],
   'bar': [],
}
extras_require['all'] = list(itertools.chain.from_iterable(extras_require.values()))
Related