[Distutils] [buildout] including optional python packages for testing

Maurits van Rees m.van.rees at zestsoftware.nl
Fri Feb 18 17:04:18 CET 2011

Op 18-02-11 16:37, Chris Withers schreef:
> On 18/02/2011 15:28, Maurits van Rees wrote:
>>> So, I'm looking for some way of specifying "optional eggs" when running
>>> the buildout, and not in buildout.cfg so they don't accidentally get
>>> checked in.
>>> How can I achieve this?
>> Next to the install_requires in setup.py you add an extras_requires;
>> here is an example from the plone.app.discussion package:
>> extras_require = {
>> 'test': [
>> 'plone.app.testing',
>> 'interlude',
>> ]
>> },
>> If you want to install these extra dependencies in e.g. a buildout
>> config, you specify plone.app.discussion[test] as an egg.
> Hmm, this isn't quite what I'm talking about.
> If I did it this way, I'd need to define an extras_require section for
> each type of database, so about 4-6 sections.
> These also aren't really dependencies of my package, since they're never
> imported by my package code, so it feels wrong to declare them as
> dependencies...

Ah, I misunderstood you.

Perhaps you could add an extra.cfg that extends buildout.cfg and adds 
the optional eggs.  Then you need to remember that you have to run 
'bin/buildout -c extra.cfg' when you want to test with those extra eggs.

Or maybe let buildout.cfg extend a local.cfg that adds the extra eggs. 
Do not add local.cfg in subversion (or whatever VCS you use) but instead 
let it ignore that file.  Add an instruction in the readme that people 
should manually add such a local.cfg and that it can remain empty.

I sometimes have only an almost empty buildout.cfg.in file in a project 
that extends a base.cfg file, with instructions to copy it to 
buildout.cfg and adapt to your local needs/wishes.


Maurits van Rees
Web App Programmer at Zest Software: http://zestsoftware.nl
Personal website: http://maurits.vanrees.org/

More information about the Distutils-SIG mailing list