[Pythonmac-SIG] Python Eggs and Mac OS version compatibility

Ronald Oussoren ronaldoussoren at mac.com
Wed Jul 20 19:10:28 CEST 2005


On 20-jul-2005, at 16:33, Kevin Dangoor wrote:

> On 7/20/05, Michael Maibaum <mike at maibaum.org> 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.

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

Ronald


More information about the Pythonmac-SIG mailing list