[Distutils] Passing in arguments to Distribution?

Mike C. Fletcher mcfletch at rogers.com
Sun Nov 21 08:17:58 CET 2004

I maintain the (rather large) PyOpenGL project, which is basically 4 
core modules plus 300+ extension modules.  One of the features I'd like 
to allow for developers is to specify that, for instance, only 1 of the 
extension modules be rebuilt during a setup pass (particularly during 
development, it can take 3 or 4 minutes just to run the configs for all 
the modules, which makes for very slow development).

The way the code currently works is that we override the Distribution 
object's "finalize_options" to search out all of the .i (SWIG) files in 
the interface sub-directory, creating an Extension object for each one 
we find.

What I'd like to do is to tell the code running in the Distribution to 
look for a global option (--extensions, for instance) and if it's 
present, restrict the set of Extensions that's being built to the list 
in the option.

However, I don't see a clean way of passing in arguments to the 
Distribution object itself.  It seems to be responsible for the parsing 
of the command line, but it assumes that it's trying to parse options 
for a particular command rather than for the overall process.

Any recipes someone cares to share?  At the moment I'm thinking I may 
just parse the options myself using getopt, but that seems like it might 
cause pain somewhere down the road. I'm going to keep experimenting to 
see if I can hack something in, but this seems like it would be a common 
requirement, so I would imagine there's a lever somewhere I can throw...

At the moment I'm thinking of moving the module discovery code into the 
main setup script, but that's still going to require parsing the options 
myself... and that seems wrong somehow...

Where-do-I-stand-and-on-what-do-I-pull-ly yr's,

  Mike C. Fletcher
  Designer, VR Plumber, Coder

More information about the Distutils-SIG mailing list