[Distutils] Re: distutils and C++ extensions

Greg Ward gward@python.net
Fri Aug 23 09:24:02 2002

On 23 August 2002, Stefan Seefeld said:
> I'v mailed to various related newsgroups/mailing lists
> but nobody answered, so please excuse for the intrusion.

Did you try distutils-sig@python.org?  That's where I send people with
distutils questions, but if you already tried there...

> I'v some trouble setting up a setup.py script for an
> extension module which I want to port from a autotools
> based build system to distutils. The module consists of
> various subdirectories, each with a set of files. The
> problem is:
> * some of the names clash (i.e. syn/hash.cc and ucpp/hash.c),
>   i.e. the way distutils works compiles different source files
>   to the same object file. I can't find a way to instruct
>   distutils to change the output file name (or directory) per
>   file

That shouldn't happen.  As I recall, distutils should compile C/C++
source as follows:

  syn/hash.cc     ->    build/temp.$plat/syn/hash.o
  ucpp/hash.c     ->    build/temp.$plat/ucpp/hash.o

(where $plat is eg. "linux-i686-2.1", ie. the OS, hardware, and Python

If that's not happening, it's a bug.

> * the different subdirectories used to have different Makefiles,
>   thus allowing different macro definitions, etc.
> * different subdirectories use different compilers (gcc vs. g++)
>   and different compiler options


> Is there any way to address these issues with distutils without
> a major hack ?

I don't think so.  I never figured out a good way to handle that stuff,
but I haven't been near the distutils since October 2000.  AFAIK no one
has figured out a good way to handle that stuff.  Sorry.

You might try multiple setup scripts, and then a meta-setup script to
tie them all together.  I think Andrew Kuchling experimented with that
sort of setup when he distutil-ized ZODB; as I recall, it sort-of
worked, but wasn't exactly a stunning success.

Greg Ward - just another Python hacker                  gward@python.net
Gee, I feel kind of LIGHT in the head now, knowing I can't make my
satellite dish PAYMENTS!