[Pythonmac-SIG] How to get setuptools to build a Universal Binary?

Christopher Barker Chris.Barker at noaa.gov
Wed Jan 7 22:20:06 CET 2009

Joe Strout wrote:
>> I just downloaded the mysqldb module from sourceforge to have a look 
>> at how it decides how to compile its C extension. It looks like it's 
>> getting the CFLAGS and LFLAGS from mysql_config. You'll need a 
>> universal binary of libmysqlclient (as Chris already pointed out).

ouch, this does complicate things a bit -- as I have no idea how to get 
a "universal" mysql_config -- it may be telling distutils to build the 
extension with only one architecture.

> OK, but to be clear, libmysqlclient isn't something from somewhere else 
> that mysqldb uses -- it's the C extension of mysqldb itself, right? 
> Something built when I do "python setup.py install" in the mysqldb 
> source directory?

nope -- see my other note.

the extensions that distutils builds will be called something like 
_mysql. It will be in site_packages, and in your app bundle, along with 
.py and .pyc files, NOT in with FrameWorks.

>> At any rate, you'll want to try to see what CFLAGS/LFLAGS were used to 
>> compile libmysqlclient. You might try to run the following command in 
>> terminal:
>> $ mysql_config --cflags

here's mine:
$ /usr/local/mysql/bin/mysql_config --cflags
-I/usr/local/mysql/include  -g -Os -arch ppc -fno-common 

Darn -- there is an "-arch ppc" in there. However, it may be that 
distutils still add the "arch i386" who knows?

if you get it to build, you can then look at what it builds, and see if 
that's Universal or not:

$ file name_of_lib

You can find what it builds in the "build" directory that distutils 
creates when you run "setup.py build". It will be in something like:


and I think will be called -mysql.so

but I don't actually have it building here.

I suppose I should try -- now that I've gone this far!


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov

More information about the Pythonmac-SIG mailing list