[Python-Dev] extensions and multiple source files with the same basename

Ronald Oussoren ronaldoussoren at mac.com
Thu May 25 15:12:01 CEST 2006


Hi,

I'm trying to port ctypes to darwin/x86 (aka the new intel macs),  
which went pretty smooth. I am running into some odd behaviour of  
distutils now that I'm trying to port those changes to the trunk.

ctypes uses libffi, which contains source files in various platform- 
specific directories, such as:

libffi/src/powerpc/ffi_darwin.c
libffi/src/x86/ffi_darwin.c

To make it possible to build a univeral binary of ctypes when -- 
enable-universalsdk is specified I'm using some preprocessor trickery  
and add both versions of the file to the source list of the _ctypes  
extension.

So far so good. This works just fine when building the out-of-tree  
copy of ctypes. However, when I build the in-tree copy of ctypes  
distutils suddenly tries compile both these source files into the  
same object file (that is both get compiled into temp.../libffi/ 
ffi_darwin.o). That obviously isn't what I want to happen.

The cause of this behaviour is CCompiler._setup_compile: this calls  
self.object_filenames with
strip_dir=True when doing a python build. Removing this argument (and  
therefore having object_filenames fall back to the default value  
False for strip_dir) doesn't seem to have bad effects on the build on  
OSX.

Does anyone know why distutils behaves like this and if it would be  
safe to change this behaviour?

Ronald




More information about the Python-Dev mailing list