On Jun 20, 2006, at 11:12 PM, Ronald Oussoren wrote:
> On Wednesday, June 21, 2006, at 03:29AM, ytrewq1
> <ytrewq1@...> wrote:
>> In a PyObjC Cocoa app which I'm writing, I'd like to
>> check whether Universal MacPython is installed.
>> Is there a recommended way of doing this?
> There isn't a recommended way for that, or rather the recommended
> way is to not care. Why do you want to know?
Probably for that QuickSilver meta-plugin, but it seems like a better
idea to just have the meta-plugin just embed a specific Python that
all of the python-based plugins depend on.
> There is way to detect this, you'll have to check if the right
> version of python is installed in /Library/Frameworks and then use
> either file(1) or macholib to detect the architectures that are
> supported by the Python shared library in the python framework.
A cheap way is to check the executable or dylib to see if it starts
with the four bytes '\xca\xfe\xba\xbe'. That's the signature for a
fat Mach-O object.
It's possible to create a fat object that only contains one arch, but
the linker doesn't do that, so it's a pretty safe bet that if it's
fat then it's universal.