Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`pip install` with all extras

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?

like image 819
Jensun Ravichandran Avatar asked Nov 04 '20 18:11

Jensun Ravichandran


People also ask

How do you install pip all modules?

You can install modules or packages with the Python package manager (pip). To install a module system wide, open a terminal and use the pip command. If you type the code below it will install the module. That will install a Python module automatically.

Does pip install all dependencies?

Pip relies on package authors to stipulate the dependencies for their code in order to successfully download and install the package plus all required dependencies from the Python Package Index (PyPI).

Can pip install multiple packages?

To pip install more than one Python package, the packages can be listed in line with the same pip install command as long as they are separated with spaces. Here we are installing both scikit-learn and the statsmodel package in one line of code. You can also upgrade multiple packages in one line of code.

What is pip install []?

pip is the package installer for Python. It is used to install, update, and uninstall various Python packages (libraries).


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,
    },
    …,
)
like image 77
phd Avatar answered Sep 20 '22 12:09

phd


I do it this way:

import itertools

extras_require = {
   'foo': [],
   'bar': [],
}
extras_require['all'] = list(itertools.chain.from_iterable(extras_require.values()))
like image 22
Michael Avatar answered Sep 18 '22 12:09

Michael