[Distutils] Adding a setuptool command that runs when setup.py build is invoked

Phillip J. Eby pje at telecommunity.com
Sat Jan 6 02:07:04 CET 2007

At 04:35 PM 1/5/2007 -0800, Scott Robertson wrote:
>I'm trying to create a package that provides a setuptool command that will 
>compile idl files when you run python setup.py build or python setup.py 
>I've figured out how to add an additional command (build_omniidl) which I 
>can run with:
>    python setup.py build_omniidl
>But I'm not sure how to wire it up so that
>   python setup.py build
>automatically invokes build_omniidl for me. Basically I want build_omniidl 
>to act just like build_python.
>Is this even possible with setuptools?

It's possible even with the distutils.  What you need is to subclass the 
distutils 'build' command class, and then pass your subclass in via the 
'cmdclass' dictionary argument to setup().

In setuptools 0.7, I plan to allow adding support for these kinds of 
extensions using entry points, so that subclassing isn't needed.

>If so anyone know where I can see an example?

Not right off, no.  Check the distutils documentation; I seem to recall it 
at least has some information about subclassing and using cmdclass.

More information about the Distutils-SIG mailing list