[Python-Dev] Mapping Darwin 8.2.0 to Mac OS X 10.4.2 in platform.py
bob at redivi.com
Thu Sep 22 05:44:31 CEST 2005
On Sep 21, 2005, at 11:26 PM, Guido van Rossum wrote:
> The platform module has a way to map system names such as returned by
> uname() to marketing names. It maps SunOS to Solaris, for example. But
> it doesn't map Darwin to Mac OS X. I think I know how to map Darwin
> version numbers to OS X version numbers: from
> http://www.opensource.apple.com/darwinsource/ it is clear that OS X
> 10.a.b corresponds to Darwin (a+4).b, except for OS X versions <=
> 10.1. I'd be happy to write the code and add it to system_alias() in
> platform.py. Is this a good idea?
No, it's not. There are other mismatches between Mac OS X version
and Darwin kernel version (e.g. 10.3.0 and 10.3.1 used the same
The only correct way to do it with public API is to use gestalt,
which platform.mac_ver() does. There are other ways (reading a
plist, parsing the output of /usr/bin/sw_vers, using the same SPI
that /usr/bin/sw_vers uses...), but gestalt is the only public API.
The one caveat with platform.mac_ver() is that it was broken for some
version(s) of Python. I don't remember when that was fixed. It
definitely works for Python 2.3.5 (ships with Mac OS X 10.4) and
Python 2.4.1, but I'm relatively certain it was broken with the
Python 2.3.0 that shipped with Mac OS X 10.3, and perhaps also the
Python 2.2.0 that shipped with Mac OS X 10.2.
Anyway, this information isn't in the uname. You can guess with the
uname, but it requires lots of special cases and maintenance.
More information about the Python-Dev