[Pythonmac-SIG] A couple of universal binary questions

Michael Glassford glassfordm at hotmail.com
Tue Jun 6 18:56:45 CEST 2006

Bob Ippolito wrote:
> On Jun 6, 2006, at 9:33 AM, Michael Glassford wrote:
>> Is it possible to build a universal binary version of a Py2App/PyObjC
>> based application that runs on pre-Tiger Macs? I assume this would
>> require doing the build on a non-Intel Mac, since you generally  
>> have to
>> build it on the earliest system version you want to run it on to  
>> get the
>> right Foundation and AppKit. If so, could you point me to more
>> information on how this is done?
> All of it works with 10.3.9 out of the box. Anything else is  
> unsupported and requires using gcc-3.3 for the PowerPC side and  
> gcc-4.0 for the Intel side. Non-trivial.

OK, thanks. That's what I needed to know.

>> What's the right way to detect within the application whether its
>> running on an Intel or a PowerPC Mac? I can figure out a way on my own
>> (such as looking at sys.byteorder), but I wonder if there's an
>> "official" way.
> The right way to detect is to not detect at all.

I realize that's generally preferable, but...

> Otherwise, it depends on what reason you're doing it. 

I'm experimenting with getting Psyco working in the application, and 
obviously only want to enable it if I'm running on an Intel machine. It 
may turn out to do this check on its own; at the moment I can't tell, 
because enabling it automatically crashes my application on both Intel 
and PowerPC Macs.

> I'd probably  
> use platform.processor(), which returns 'i386' or 'powerpc'.. but it  
> returns 'powerpc' for ppc64 as well, so you might also want to check  
> platform.architecture()[0] to be safe. You could probably also do  
> these with sysctl.

In addition to these methods, I discovered that Pysco's setup.py has this:

class ProcessorAutodetectError(Exception):
def autodetect():
     platform = sys.platform.lower()
     if platform.startswith('win'):   # assume an Intel Windows
         return 'i386'
     # assume we have 'uname'
     mach = os.popen('uname -m', 'r').read().strip()
     if not mach:
         raise ProcessorAutodetectError, "cannot run 'uname -m'"
         return {'i386': 'i386',
                 'i486': 'i386',
                 'i586': 'i386',
                 'i686': 'i386',
                 'i86pc': 'i386',    # Solaris/Intel
                 'x86':   'i386',    # Apple
     except KeyError:
         raise ProcessorAutodetectError, "unsupported processor '%s'" % mach



More information about the Pythonmac-SIG mailing list