Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify extras_require with pip install -e

Tags:

git

python

pip

How can one manage to install extras_requires with pip when installing from a git repository ?

I know that you can do pip install project[extra] when the project is on pypi.
And you have to do pip install -e git+https://github.com/user/project.git#egg=project for a git repo but I didn't manage to find how to link these two options together.

like image 762
PhilipGarnero Avatar asked May 14 '15 13:05

PhilipGarnero


People also ask

What is Extras_require?

extras_require. A dictionary mapping names of “extras” (optional features of your project) to strings or lists of strings specifying what other distributions must be installed to support those features. and. install_requires.

What is setup CFG python?

setup. cfg is a cheekily named Python package which supports providing all of a Python distribution's metadata and build configuration via the setup. cfg file at the base of the distribution's source tree, rather than in the setup.py script. The standard setup.py script is reduced to a stub which uses the setup.

What is setup py?

setup.py is a python file, the presence of which is an indication that the module/package you are about to install has likely been packaged and distributed with Distutils, which is the standard for distributing Python Modules. This allows you to easily install Python packages.

What is Pyproject TOML?

The pyproject. toml file was introduced in PEP-518 (2016) as a way of separating configuration of the build system from a specific, optional library (setuptools) and also enabling setuptools to install itself without already being installed.


2 Answers

This should work, per example #6

For remote repos:

pip install -e git+https://github.com/user/project.git#egg=project[extra]

And this for local ones (thanks to @Kurt-Bourbaki):

pip install -e .[extra]

As per @Jurt-Bourbaki:

If you are using zsh you need to escape square brackets or use quotes:

pip install -e .\[extra\]
# or
pip install -e ".[extra]"
like image 107
Alik Avatar answered Oct 16 '22 07:10

Alik


Important to notice: you should not have whitespaces around or within brackets. I.e. this will work: -e ".[extra1,extra2]" but this won't: -e ". [extra1, extra2]" - and even as a row in requirements.txt file, where it is not so obvious. The worst thing about it is that when you have whitespace, extras are just silently ignored.

like image 38
MarSoft Avatar answered Oct 16 '22 08:10

MarSoft