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

Joe Strout joe at strout.net
Wed Jan 7 21:40:06 CET 2009


Christopher Barker wrote:

> sorry to hear that you are still struggling with this.

I appreciate the sympathy (and the help).

>> 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)

But that's what I was doing:

    <http://www.dotancohen.com/howto/python-app-mac.html>

...unless there is some step I've missed?

>> 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.

That's how it seemed to me too.

> 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.

This appears to be the problem, I think.

> 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.

The only other extension involved, as far as I can tell, is wx, and that 
one is already universal.

> 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's what I'm trying to figure out how to do.  (libmysqlclient is the 
library behind MySQLdb, as far as I can tell.)

> 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.

What is this "configure" you speak of?  MySQLdb doesn't use the 
configure/make dance which is standard for Unix libraries; it uses 
setuptools (which appears to be standard for Python libraries).  If it's 
using configure or make, it's doing so under the hood.  Any idea how I 
would specify universal or arch in this case?

> Next best case:
> 
> You can pass in either PPC or x86 separately, building two versions and 
> then lipo-ing them together.

Same question as above.

> 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.

I suppose.

> 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.

I gave up on that one a while back -- all this is being done on a 10.4 
(Intel) machine.  I can do it all again on a PPC machine if necessary.

> 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.

This is exactly the question I was asking how to do.  But you seem to 
think that libmysqlclient is something other than MySQLdb.  I'm under 
the impression that it's the same thing.  The only other library in my 
"Frameworks" folder is libwx_macud-2.8.0.dylib, which I presume is 
wxPython.  (This one already is a universal binary.)

> 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 think you're still imagining libmysqlclient as being something MySQLdb 
depends on, rather than the MySQLdb extension itself.

> 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.

Maybe -- I got a UB of MySQL itself, so I don't think that's the 
problem.  (But of course it's entirely possible that I'm more confused 
than I realize.)

> 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!

No kidding!  I've spent more time futzing around with this than I have 
writing the app itself.  It's fairly ridiculous, and I'm now to the 
point where I have to seriously consider whether it's worth continuing 
this project in Python, or spend a day or two rewriting it in REALbasic.

I feel like I'm close, though -- if I can just figure out how to make a 
UB of this libmysqlclient thing, I think I'll be there.

Thanks,
- Joe

P.S. While people have been very generous with their free help and 
advice, if anyone could be more motivated to spend a few hours on it as 
a paid consulting gig, I'd be happy to pay.




More information about the Pythonmac-SIG mailing list