[Numpy-discussion] Problem with numpy and distutils on OS X

Michele Vallisneri vallis.35530053 at bloglines.com
Fri May 9 12:17:50 EDT 2008


I'm writing a standard distutils setup.py to compile a Python C  
extension on OS X 10.4, and I need to specify a few special compiler  
options to enable vector CPU extension (altivec and SSE on i686 and  
PPC respectively). This compromises the generation of universal  
binaries, because these options are CPU-specific, and cannot be  
passed to gcc together with "-arch ppc -arch i386".

I'm happy with generating a nonuniversal extension, which I can do  
(at least with distutils 2.4.4) by specifying an extra "-arch i386"  
compiler option. Distutils has some Darwin-specific code that catches  
that, and takes out the "-arch ppc" option that would be there by  
default.

All well, but then in my setup.py I also import numpy (to find out  
where its C includes are). If I do that, the behavior of distutils  
changes, and the "-arch ppc" option is not taken out, so compilation  
fails again.

So I have questions:

- Is this an acceptable behavior for numpy to have? Should it modify  
other modules? I understand that there is a numpy.distutils, but  
shouldn't I have a choice to use it explicitly, and get the old  
distutils behavior by using that namespace?

- Is there a way to avoid or disable this interference?

- Finally, is there a way to compile universal binaries with CPU- 
specific options?

My python is 2.4.4. My numpy is version 1.0.4. gcc is 4.0.1.

Thanks a lot!

Michele





More information about the NumPy-Discussion mailing list