[PyObjC-svn] r2234 - trunk/pyobjc/pyobjc-core/Lib/PyObjCTools

[email protected] Sat, 23 May 2009 01:56:27 -0500
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Sat May 23 01:56:27 2009
New Revision: 2234

Log:
Add function to TestSupport to detect the version of the SDK used to
compile Python itself. Needed because some functionality is different
depending on the SDK version used to link code.


Modified:
   trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py

Modified: trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py	Sat May 23 01:56:27 2009
@@ -12,12 +12,36 @@
 import subprocess as _subprocess
 import sys as _sys
 import struct as _struct
+from distutils.sysconfig import get_config_var as _get_config_var
+import re as _re
 
 # Have a way to disable the autorelease pool behaviour
 _usepool = not _os.environ.get('PYOBJC_NO_AUTORELEASE')
 _useleaks = bool(_os.environ.get('PyOBJC_USE_LEAKS'))
 _leaksVerbose = True
 
+def sdkForPython(_cache=[]):
+    """
+    Return the SDK version used to compile Python itself,
+    or None if no framework was used
+    """
+    if not _cache:
+
+        cflags = _get_config_var('CFLAGS')
+        m = _re.search('-isysroot ([^ ]*) ', cflags)
+        if m is None:
+            return None
+
+        path = m.group(1)
+        bn = _os.path.basename(path)
+        version = bn[6:-4]
+        if version.endswith('u'):
+            version = version[:-1]
+
+        return map(int, version.split('.'))
+
+    return _cache[0]
+
 def fourcc(v):
     """
     Decode four-character-code integer definition

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com