On Jul 20, 2005, at 7:10 AM, Ronald Oussoren wrote:

>
> On 20-jul-2005, at 16:33, Kevin Dangoor wrote:
>
>
>> On 7/20/05, Michael Maibaum <[EMAIL PROTECTED]> wrote:
>>
>>
>>> On 20 Jul 2005, at 13:36, Kevin Dangoor wrote:
>>>
>>>
>>>> That is more comforting than going with the Darwin version. I'll
>>>> wrap
>>>> that up for Phillip and send him a patch.
>>>>
>>>>
>>>
>>>
>>> Note that the 3 or 4 people in the world running (pure) Darwin
>>> systems will not have sw_vers as it is not part of Darwin.
>>>
>>>
>>
>> Believe it or not, I actually thought of that as well. Don't worry, I
>> have those handful of people covered as well...
>>
>>     if sys.platform == "darwin":
>>         try:
>>             version = macosx_vers()
>>             machine = os.uname()[4].replace(" ", "_")
>>             return "macosx-%d.%d.%d-%s" % (int(version[0]), int
>> (version[1]),
>>                 int(version[2]), machine)
>>         except ValueError:
>>             # if someone is running a non-Mac darwin system, this
>> will fall
>>             # through to the default implementation
>>             pass
>>
>>     from distutils.util import get_platform
>>     return get_platform()
>>
>> On my machine, this returns:
>> macosx-10.4.2-Power_Macintosh
>>
>
> You don't mention the implementation of macosx_vers, but instead of
> calling /usr/bin/sw_vers you could also use platform.mac_ver,
> something like:
>
>      if sys.platform == "darwin":
>          import platform
>          ver = platform.mac_ver()[0]
>          if ver != '':
>              return "macosx-%s.%s-%s"%tuple(ver.split('.')[:2] +
> [ platform.machine().replace(' ', '_') ])
>          # fall through to the generic version
>
> This would return 'macosx-10.4-Power_Macintosh' on my system. Note
> that I explicitly drop the micro release number because OSX is binary
> compatible across all micro-releases in a release.

IIRC platform.mac_ver() was broken for some versions of Python (2.3.0  
maybe?), and doesn't work on Intel machines because it uses gestalt  
and there's that pesky four character code endian issue.  Calling  
sw_vers works everywhere, and you only do it once (the function is  
"memoized")

>>
>> I thought it made sense to leave the Power_Macintosh in there because
>> of the upcoming Intel switch. I don't want to think about "Universal
>> Binary" eggs right now :)
>>
>
> "Universal Binary" eggs should be automatic once someone teaches
> distutils to build "Univeral Binary" extensions. Building such
> extensions is easy enough (there's a hack in PyObjC's setup.py to do
> so), nicely integrating that in distutils is harder.

Yes and no.  Depends on what you're compiling.  It's probably better  
to use ppc and i386 as the mnemonics because "Power Macintosh" isn't  
what the toolchain understands (e.g. gcc, lipo, etc.), and you're not  
going to be able to ask uname "what's the arch name for the other  
architecture(s) that my computer isn't".

-bob

_______________________________________________
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to