[Distutils] Can now compile simple extensions

Greg Ward gward@cnri.reston.va.us
Thu, 19 Aug 1999 12:01:09 -0400

Hi all --

at long last, I found the time to hack in the ability to compile
extension modules to the Distutils.  Mainly, this meant adding a
'build_ext' command which uses a CCompiler instance for all its dirty
work.  I also had to add a few methods to CCompiler (and, of course,
UnixCCompiler) to make this work.

And I added a new module, 'spawn', which takes care of running
sub-programs more efficiently and robustly (no shell involved) than
os.system.  That's needed, obviously, so we can run the compiler!

If you're in the mood for grubbing over raw source code, then get the
latest from CVS or download a current snapshot.  See


for a link to the code snapshot.

I'm still waiting for more subclasses of CCompiler to appear.  At the
very least, we're going to need MSVCCompiler to build extensions on
Windows.  Any takers?  Also, someone who knows the Mac, and how to run
compilers programmatically there, will have to figure out how to write a
Mac-specific concrete CCompiler subclass.

The spawn module also needs a bit of work to be portable.  I suspect
that _win32_spawn() (the intended analog to my _posix_spawn()) will be
easy to implement, if it even needs to go in a separate function at all.
It looks from the Python Library documentation for 1.5.2 that the
os.spawnv() function is all we need, but it's a bit hard to figure out
just what's needed.  Windows wizards, please take a look at the
'spawn()' function and see if you can make it work on Windows.

As for actually compiling extensions: well, if you can figure out the
build_ext command, go ahead and give it a whirl.  It's a bit cryptic
right now, since there's no documentation and no example setup.py. (I
have a working example at home, but it's not available online.)  If you
feel up to it, though, see if you can read the code and figure out
what's going on.  I'm just hoping *I'll* be able to figure out what's
going on when I get back from the O'Reilly conference next week... ;-)

Enjoy --

Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                           voice: +1-703-620-8990
Reston, Virginia, USA  20191-5434                    fax: +1-703-620-0913