Search code examples
pythonpypi

Optional dependencies for PyPI packages


I want to create a new PyPI package, but this will have an special wheels where I will invoke it like this:

pip install misoftware[customer1]

Is this possible?

If so how can I provide patches for [customer1]

For example my main release is:

misoftware==1.1 and

misoftware[customer1]

I want

misoftware[customer1]==1.1.2

This will be 3 wheels total


Solution

  • You're describing setuptools 'extras'. This allows you to specify additional dependencies, so for example

    • misoftware just installs the misoftware package
    • misoftware[customer1] would install the misoftware package, plus some extra dependencies

    The downside is that the dependencies you list in your extras must be hosted as packages themselves as well on PyPI. So you'd need to create a misoftware_customer1 package, and so on.