[Pythonmac-SIG] How to get setuptools to build a Universal Binary?
Christopher Barker
Chris.Barker at noaa.gov
Wed Jan 7 21:18:55 CET 2009
Joe,
sorry to hear that you are still struggling with this.
Joe Strout wrote:
> I'm (still) trying to make a neatly packaged Python app that works on
> both PPC and Intel Macs. All is good except for mysqldb; following the
> procedure I've documented at
> <http://www.dotancohen.com/howto/python-app-mac.html>, my app bundle
> contains an Intel-only binary of the mysqldb library
> (libmysqlclient_r.16.dylib).
> This page
> (http://developer.apple.com/opensource/buildingopensourceuniversal.html)
> at Apple suggests a possible solution: build separate Intel and PPC
> binaries, and then combine them with lipo.
that's actually pretty easy to do.
> So: does anyone have a clue how I can convince setuptools to build a PPC
> binary (or better yet, a Universal one) on an Intel machine?
setuptools using distutils to build, and distutils should build a
Universal binary if you run it with a Universal Python (the python .org one)
> This may or may not also be involved:
> <http://bugs.python.org/setuptools/issue19>
I don't think so. I think the issue there is with easy_install getting
confused when you try to install a Universal binary.
> Any advice will be greatly appreciated...
I'm not familiar with MySQLDB, but there are two issues at hand when
building Universal extensions:
1) making the extension Universal -- that SHOULD be taken care of by
distutils.
2) making sure all the libs that the extension depends on are Universal
-- you have to do this first, and it has nothing to do with setuptools,
or distutils, or even python.
It looks like you have a libmysqlclient dependency -- which makes sense
-- you need to find a way to get a Universal one of those.
That apple page you referenced should help guide you.
Best case:
If the lib source has been tweaked to be able to build universal, you
may be able to pass a flag like "universal" into configure, if you're
really lucky, otherwise, sometimes passing in both arch=PPC and arch=x86
or something like that can work.
Next best case:
You can pass in either PPC or x86 separately, building two versions and
then lipo-ing them together.
Worst case:
Some code can only be built for the architecture the compiler is run on,
due to how they detect endianess, etc. In this case you need to build
one on PPC, and one on Intel, and then move them to the same machine to
lipo them together.
The other complication is that you need to make sure to use the right
SDK, if you want o build on 10.5 and allow it to run on 10.4.
Anyway, the short version is that I think you need to dig around the net
for info on how to build libmysqlclient Universal -- hopefully someone
has done it and distributes a binary, but presumably you've already
looked for that.
One last note: usually, when folks want to distribute a python extension
that depends on a lib that Apple does not provide, they build that lib
statically, then link that version into their extension, so you don't
have to worry about distributing it -- same issue with Universal, though.
I quick poking around tells me that MySQL themselves distribute Intel
and PPC binaries separately -- I suspect you could get each of those,
and pull the libs out and libo them together. This may be easier than
building it yourself.
A couple helpful pages you've probably already found:
http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg
http://developer.apple.com/internet/opensource/osdb.html
http://davidmichaelthompson.com/?p=12
I hope that helps,
-Chris
PS: I'm really surprised that no one seems to have done this already,
and posted a binary egg or something! MySQLdb is not a minor package!
--
Christopher Barker, Ph.D.
Oceanographer
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