Pyrex and Distuils: an enhanced build_ext command

Graham Fawcett gmfawcett at operamail.com
Wed Jul 10 14:16:34 EDT 2002


"Thomas Heller" <theller at python.net> wrote in message news:<agh6bc$lfrlg$1 at ID-59885.news.dfncis.de>...
> 
> 1. The 'official' way to replace a standard distutils command
> class is done in the following way: Derive your class, say
> 'my_build_ext', from the standard distutils command:
> 
> class my_build_ext(build_ext):
>    ....
> 
> and then pass a cmdclass parameter to the setup command:
> setup(...
>       cmdclass = {'build_ext': my_build_ext},
>       ...)

Ironically, Thomas, you inspired the approach that I took -- I
borrowed it from py2exe. ;-) But, all things being equal, "simple and
explicit" always trumps "import hack". Thanks, I'll take this into
account.

> 2. Looking at distutils command.build_ext source, there is already
> a method which 'precompiles' source files into .c files, it's the
> swig_sources() method. Sound a little hackish, but probably we could
> get away with just overriding this method in the my_build_ext class.
> Maybe something like the swig_sources() command should be promoted
> into an 'official' hook for precompilation?

When I subclassed build_ext, I just cut out the swig_sources() method,
assuming it was SWIG-specific. But I see the analogy and agree that
this would be a clean place to put the "pyrexc" code.

Thanks, Thomas,

-- Graham



More information about the Python-list mailing list