[SciPy-dev] OS X universal SciPy: success!

Josh Marshall josh.p.marshall at gmail.com
Tue Aug 14 05:03:20 EDT 2007


I've been trying to easily build an OS X universal SciPy for some  
time now. [1] My prior efforts consisted of lipo-ing together the PPC  
and x86 'Superpacks' put together by Chris Fonnesbeck [2], which  
worked for distributing my image processing app locally. However,  
this isn't really a good way to do it, specially not for putting up  
for general use.

I came across a successful Universal build of gfortran [4,5], and  
then shortly found this message [5] claiming it could possibly be  
used to build a universal SciPy.

So, I gave it a shot and it works! (with some tricks...)

The build has both ppc and i386 architectures in every .so in the  
scipy install. The tests run fine on my G4, but I haven't yet had the  
chance to try it on an Intel Mac. If anyone is keen to do so, please  
let me know.

There will need to be some modifications to numpy distutils, since it  
presumes that there isn't a universal Fortran. The patch below is  
just a hack to get it working, and will break any non-universal  
gfortran. Essentially, all that needs to happen is to have '-arch ppc  
-arch i386' added to any call to gfortran (both compile and link) ,  
and the '-march' flags removed.

What's the best way to add this functionality to numpy distutils? I  
couldn't think of any way to test for a universal compiler, other  
than trying to compile a test file and seeing if it dies with the  
multiple arch flags.

Regards,
Josh Marshall


[1] http://mail.python.org/pipermail/pythonmac-sig/2006-December/ 
018556.html
[2] http://trichech.us/?page_id=5
[3] http://r.research.att.com/tools/
[4] http://r.research.att.com/gfortran-4.2.1.dmg
[5] http://mail.python.org/pipermail/pythonmac-sig/2007-May/018975.html

isengard:~/Development/Python/numpy-svn/numpy/distutils/fcompiler Josh 
$ svn diff gnu.py
Index: gnu.py
===================================================================
--- gnu.py      (revision 3964)
+++ gnu.py      (working copy)
@@ -102,6 +102,7 @@
                  minor)

              opt.extend(['-undefined', 'dynamic_lookup', '-bundle'])
+            opt.extend(['-arch ppc -arch i386'])
          else:
              opt.append("-shared")
          if sys.platform.startswith('sunos'):
@@ -183,12 +184,13 @@
              # Since Apple doesn't distribute a GNU Fortran  
compiler, we
              # can't add -arch ppc or -arch i386, as only their version
              # of the GNU compilers accepts those.
-            for a in '601 602 603 603e 604 604e 620 630 740 7400  
7450 750'\
-                    '403 505 801 821 823 860'.split():
-                if getattr(cpu,'is_ppc%s'%a)():
-                    opt.append('-mcpu='+a)
-                    opt.append('-mtune='+a)
-                    break
+            #for a in '601 602 603 603e 604 604e 620 630 740 7400  
7450 750'\
+            #        '403 505 801 821 823 860'.split():
+            #    if getattr(cpu,'is_ppc%s'%a)():
+            #        opt.append('-mcpu='+a)
+            #        opt.append('-mtune='+a)
+            #        break
+            opt.append('-arch ppc -arch i386')
              return opt




More information about the SciPy-Dev mailing list