Specify extras_require with pip install -e

PythonGitPip

Python Problem Overview


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.

Python Solutions


Solution 1 - Python

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]"

Solution 2 - Python

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.

Solution 3 - Python

This also works when installing from a whl file so, for example, you can do:

pip install path/to/myapp-0.0.1-py3-none-any.whl[extra1]

This is very far from clear from the docs, and not particularly intuitive.

Solution 4 - Python

Using git + ssh to install packages with extras from private repositories:

pip install -e 'git+ssh://[email protected]/user/project.git#egg=project[extra1,extra2]'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPhilipGarneroView Question on Stackoverflow
Solution 1 - PythonAlikView Answer on Stackoverflow
Solution 2 - PythonMarSoftView Answer on Stackoverflow
Solution 3 - PythonAntonOfTheWoodsView Answer on Stackoverflow
Solution 4 - PythonConnor DibbleView Answer on Stackoverflow