[Distutils] setuptools extras_require

Tres Seaver tseaver at palladion.com
Fri Feb 9 15:29:19 CET 2007

Hash: SHA1

Matt Good wrote:
> On Thu, 2006-12-14 at 07:15 +0100, Elvelind Grandin wrote:
>> Perhaps I wasn't totally clear. what I meant was something like this.
>> extras_require = {
>> 	        "default" : ["SQLObject==bugfix,>=0.7.1dev-r1860,<=0.7.99"],
>>  	        "future" : ["Genshi>=0.3", "SQLAlchemy>=0.3"]
>>  	    },
> That may be ok for the example, but what happens if you add another
> extra "foo" for some optional feature.  Installing "TurboGears[foo]"
> won't select either the "default" or "future" extras, so you don't
> really get all the requirements.
>>From a semantic perspective I think listing these as "extras" is odd.
> One of either SQLObject or SQLAlchemy is required for installation, so
> it's not just an "extra" feature.  I think extras have been used for
> this as a workaround to setuptools not supporting ORed requirements, but
> I'd like to see that fixed.  I tend to think in terms of Debian packages
> where stuff like SA or SO would be listed as "depends" meaning that
> they're strictly required, so in setuptools this would correspond to
> "install_requires".  On the other hand I believe Paste is still an
> optional package used in TurboGears for stuff like the interactive
> traceback display, so it'd be a Debian "recommends", or setuptools
> "extras".
> Using "|" as a separator for ORing TurboGear's requirements might look
> something like this (ignoring version numbers for simplicity):
> install_requires = [
>         "SQLObject | SQLAlchemy",
>         "Kid | Genshi",
> ],
> extras_require = {
>         "fancy_tb": ["Paste"],
> }

+1 for the pipe symbol:  to my eye, it means "pick the first of these",
which is what you want.

> Setuptools would check if either SQLObject or SQLAlchemy was already
> installed, if not it'd try from left to right until it successfully
> installed one of the requirements.
> I suppose extras could still be used as aliases for something like the
> "future" requirements to make it easier for users to install this set of
> packages:
> extras_require = {
>         "standard": ["Kid", "SQLObject"],
>         "future": ["Genshi", "SQLAlchemy"],
>         "fancy_tb": ["Paste"],
> }
> Alternatively tuples could be substituted to define ORed requirements
> like:
> install_requires = [
>         ("SQLObject", "SQLAlchemy"),
>         ("Kid", "Genshi"),
> ]
> Comments?

I have a need for the "alternate dependencies" myself, e.g.:

  install_requires = ['lxml | elementtree']

where my package prefers lxml, but can fall back to using elementtree.

- --
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the Distutils-SIG mailing list