[Distutils] C extensions with non-uniform compiler options

Konrad Hinsen hinsen at cnrs-orleans.fr
Tue Feb 20 17:09:46 CET 2007

I need to build a C extension consisting of several C code files, one  
of which needs to be compiled with different compiler options. There  
doesn't seem to be a standard way to do this.

As a workaround I added a dummy extension that uses that file, and  
specified the necessary compiler options for that extension. Then I  
removed the source file from the file list of the real extension and  
replaced it by an entry in extra_objects. The idea is the re-use the  
version compiled for the dummy extension module.

However, there are two problems:

1) The documentation for extra_objects states that "These files must  
not have extensions, as the default extension for the compiler is  
used."  That would be nice, but isn't true: on my Mac, the required  
".o" is not added.

2) The object file I wish to add has been created in "build/ 
temp.macosx-10.3-fat-2.5", but this directory is machine-specific. I  
need to construct this path in a portable way - but how?

Did anyone already solve these problems, or find another solution?

Thanks in advance,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2745 bytes
Desc: not available
Url : http://mail.python.org/pipermail/distutils-sig/attachments/20070220/20c10a02/attachment.bin 

More information about the Distutils-SIG mailing list