diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2006-05-23 12:01:11 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2006-05-23 12:01:11 (GMT) |
commit | b02daf794b9be0041dc39207f18211ec8321ec77 (patch) | |
tree | 421b1ca9eec422f78d0bd54b9066069eca2ca797 /Lib/distutils/util.py | |
parent | 58f8eba372be06d20541b5e58244e92071e7417e (diff) | |
download | cpython-b02daf794b9be0041dc39207f18211ec8321ec77.zip cpython-b02daf794b9be0041dc39207f18211ec8321ec77.tar.gz cpython-b02daf794b9be0041dc39207f18211ec8321ec77.tar.bz2 |
Patch #1488098.
This patchs makes it possible to create a universal build on OSX 10.4 and use
the result to build extensions on 10.3. It also makes it possible to override
the '-arch' and '-isysroot' compiler arguments for specific extensions.
Diffstat (limited to 'Lib/distutils/util.py')
-rw-r--r-- | Lib/distutils/util.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py index 061092b..623c41e 100644 --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -67,6 +67,54 @@ def get_platform (): m = rel_re.match(release) if m: release = m.group() + elif osname[:6] == "darwin": + # + # For our purposes, we'll assume that the system version from + # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set + # to. This makes the compatibility story a bit more sane because the + # machine is going to compile and link as if it were + # MACOSX_DEPLOYMENT_TARGET. + from distutils.sysconfig import get_config_vars + cfgvars = get_config_vars() + + macver = os.environ.get('MACOSX_DEPLOYMENT_TARGET') + if not macver: + macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET') + + if not macver: + # Get the system version. Reading this plist is a documented + # way to get the system version (see the documentation for + # the Gestalt Manager) + try: + f = open('/System/Library/CoreServices/SystemVersion.plist') + except IOError: + # We're on a plain darwin box, fall back to the default + # behaviour. + pass + else: + m = re.search( + r'<key>ProductUserVisibleVersion</key>\s*' + + r'<string>(.*?)</string>', f.read()) + f.close() + if m is not None: + macver = '.'.join(m.group(1).split('.')[:2]) + # else: fall back to the default behaviour + + if macver: + from distutils.sysconfig import get_config_vars + release = macver + osname = "macosx" + + + if (release + '.') < '10.4.' and \ + get_config_vars().get('UNIVERSALSDK', '').strip(): + # The universal build will build fat binaries, but not on + # systems before 10.4 + machine = 'fat' + + elif machine in ('PowerPC', 'Power_Macintosh'): + # Pick a sane name for the PPC architecture. + machine = 'ppc' return "%s-%s-%s" % (osname, release, machine) |