Optional dependencies in distutils / pip

Mike Cooper picture Mike Cooper · Jun 4, 2011 · Viewed 13.5k times · Source

When installing my python package, I want to be able to tell the user about various optional dependencies. Ideally I would also like to print out a message about these optional requirements and what each of them do.

I haven't seen anything yet in the docs of either pip or docutils. Do tools these support optional dependencies?

Answer

Tobu picture Tobu · Dec 3, 2012

These are called extras, here is how to use them in your setup.py.

The base support is in pkg_resources. You need to enable distribute in your setup.py. pip will also understand them:

pip install 'package[extras]'