[Pythonmac-SIG] building universal binaries

Bob Ippolito bob at redivi.com
Fri Feb 3 13:00:06 CET 2006


On Feb 2, 2006, at 8:23 PM, Bob Ippolito wrote:

>
> On Jan 27, 2006, at 8:31 AM, Ronald Oussoren wrote:
>
>>
>> On 27-jan-2006, at 16:38, bear wrote:
>>
>>> Ronald Oussoren wrote:
>>>>
>>>> On 27-jan-2006, at 4:22, bear wrote:
>>>>
>>>>> Ronald Oussoren wrote:
>>>>>> That part is easy enough. If you want a framework build you'll
>>>>>> have to patch Makefile.pre.in because it contains a hardcoded '-
>>>>>> arch ppc' in the section that builds that actual framework.
>>>>>> Otherwise it should just build (assuming you have an intel mac
>>>>>> of course, cross-building from PPC to Intel will be hard
>>>>>> because the build process assumes you'll do a native build).
>>>>> ok, I found the relevant part in configure (and cofigure.in)
>>>>> that was putting -arch_only ppc into the Makefile and I've re-
>>>>> run configure and it seems happy - heck, even the compiling ran
>>>>> error free.
>>>>>
>>>>> But when it got to the link part - I get the following error:
>>>>
>>>> You must replace the -arch ppc part by -arch i386. If you want to
>>>> build a universal binary you'll have to replace the call to
>>>> libtool by something more complex. I'll see if I can produce a
>>>> patch later today.
>>> Coolness - I was able to get a clean build of python for the i386
>>> arch just now.  I did have to apply a patch to Lib/plat-mac/
>>> applesingle.py so that it would run without errors.  I got the
>>> required patch from http://www.opensource.apple.com/darwinsource/
>>> tarballs/other/python-16.tar.gz that Kevin mentioned in an earlier
>>> post to this thread.
>>>
>>> Now to build the rest of our app and see how it fairs ;)
>>>
>>
>> From my Makefile.pre.in:
> ---
>> This is very ugly. As you have noted you can't just drop -arch ppc
>> because libtool than assumes that you want to do a 3-way universal
>> build. Probably because libSystem contains a ppc64 binary.
>>
>> I hope to have a script for building a "batteries included"
>> universal build of python by the end of this weekend.
>
> I've made a private branch of python24-maint via SVK that's probably
> most of the way there.  It fixes a couple of the endian issues in the
> Mac modules (platform.mac_ver, applesingle, gestalt, and the OSType
> converter functions) and fixes enough of the configure/make/autoconf
> crap so that it cleanly builds on either ppc or i386 (with just one
> compiler, and not yet universal):
>
> http://svn.red-bean.com/bob/python24-fat

I've got universal working against the 10.4u SDK at the same svn URL,  
even building from a PPC host.

$ arch; sw_vers
ppc
ProductName:    Mac OS X
ProductVersion: 10.4.4
BuildVersion:   8G32
$ svn co http://svn.red-bean.com/bob/python24-fat
...
$ cd python24-fat
$ mkdir _build; cd _build
$ ../configure --enable-universalsdk --enable-framework && make
...
$ lipo -info python.exe Python.framework/Versions/2.4/Python  
libpython2.4.a build/lib.macosx-10.4.4-fat-2.4/gestalt.so
Architectures in the fat file: python.exe are: ppc i386
Architectures in the fat file: Python.framework/Versions/2.4/Python  
are: ppc i386
Architectures in the fat file: libpython2.4.a are: ppc i386
Architectures in the fat file: build/lib.macosx-10.4.3-fat-2.4/ 
gestalt.so are: ppc i386
$ DYLD_FRAMEWORK_PATH=. ./python.exe -c "from distutils.util import  
get_platform as p; print p()"
$ DYLD_FRAMEWORK_PATH=. ./python.exe -c "import platform; print  
platform.mac_ver()"

.. and on an i386 box:

$ arch; sw_vers
i386
ProductName:    Mac OS X
ProductVersion: 10.4.3
BuildVersion:   8F1099
$ DYLD_FRAMEWORK_PATH=. ./python.exe -c "from distutils.util import  
get_platform as p; print p()"
macosx-10.4.3-fat
$ DYLD_FRAMEWORK_PATH=. ./python.exe -c "import platform; print  
platform.mac_ver()"
('10.4.3', ('', '', ''), 'i386')
$ DYLD_FRAMEWORK_PATH=. /usr/libexec/oah/oah750 ./python.exe -c  
"import platform; print platform.mac_ver()"
('10.4.3', ('', '', ''), 'PowerPC')

The only thing "wrong" with this build, as far as I can tell, is that  
it very likely isn't going to work on Mac OS X 10.3.  I'm not very  
interested in fixing this myself, especially because I don't have a  
10.3 machine around.

Clearly I had to make a bunch of changes to configure.in,  
Makefile.pre.in, some of the Mac modules, and distutils (so it gets  
the platform_name correct.  The resultant is really fat, not the host  
arch.. especially important for setuptools).

There is some more work that needs to be done with regard to  
distribution, but I think it's pretty close.

-bob


More information about the Pythonmac-SIG mailing list