Search code examples
pythonpipeasy-installsetup.pyegg

Negative extra_requires in Python setup.py


I'd like to make a Python package that installs a dependency by default unless the user specially signals they do not want that.

Example:

 pip install package[no-django]

Does current pip and setup.py mechanism provide way to do this or does not need to have explicit extra_requires every time?


Solution

  • I don't think this is possible. A way around it is to do a normal extra requires ... where

    install_require=[
        # ...
        # no django listed here
    ],
    extras_require={
        'django': ['django'],
    }
    

    and install with package[django] everywhere you need django installed.