[PyObjC-svn] r2225 - trunk/pyobjc/pyobjc-core

[email protected] Wed, 20 May 2009 15:29:21 -0500
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Wed May 20 15:29:21 2009
New Revision: 2225

Log:
Fix issue in setup.py: we tried to compile using '-isysroot /', but didn't do the same fixup
for linking. This causes PyObjC to get linked against the 10.4 SDK (at least when using a 
Python.org build of python), while building compiled against the system headers. 

Side effect of that: hard crash in a number of unittests (probably because PyObjC tries to use 
symbols that cannot be resolved when you link to the 10.4 framework).


Modified:
   trunk/pyobjc/pyobjc-core/NEWS.txt
   trunk/pyobjc/pyobjc-core/setup.py

Modified: trunk/pyobjc/pyobjc-core/NEWS.txt
==============================================================================
--- trunk/pyobjc/pyobjc-core/NEWS.txt	(original)
+++ trunk/pyobjc/pyobjc-core/NEWS.txt	Wed May 20 15:29:21 2009
@@ -7,8 +7,10 @@
 Version 2.2 (...)
 -----------------
 
-- Fix crash when using the animotor proxy feature of CoreAnimation. That is,
-  the following code now works::
+- BUGFIX: Enable building from source with the Python.org binary distribution.
+
+- BUGFIX: Fix crash when using the animotor proxy feature of CoreAnimation. 
+  That is, the following code now works::
 
 	app = NSApplication.sharedApplication()
 	window = NSWindow.alloc().init()

Modified: trunk/pyobjc/pyobjc-core/setup.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/setup.py	(original)
+++ trunk/pyobjc/pyobjc-core/setup.py	Wed May 20 15:29:21 2009
@@ -84,18 +84,54 @@
     print ""
     raise SystemExit("ObjC runtime not found")
 
+from distutils.sysconfig import get_config_var
+cc = get_config_var('CC')
+
+CFLAGS=[]
+
+if cc == 'XXXgcc':
+    # This is experimental code that tries to avoid refering to files in 
+    # /Library/Frameworks or /usr/local.
+    # 
+    # NOTE: This is not enabled by default because the linker will still look
+    # in /usr/local/lib and /Library/Frameworks...
+
+    fp = os.popen('cpp -v </dev/null 2>&1', 'r')
+    dirs = []
+    started = False
+    for ln in fp:
+        if not started:
+            if ln.startswith('#include <...> search starts here:'):
+                started=True
+            continue
+
+        else:
+            ln = ln.strip()
+            if not ln.startswith('/'):
+                break
+
+            if ln == '/usr/local/include':
+                continue
+
+            elif ln == '/Library/Frameworks':
+                continue
+
+            if ln.endswith('(framework directory)'):
+                dirs.append(('framework', ln.split()[0]))
+            else:
+                dirs.append(('system', ln))
+
+    if dirs:
+        CFLAGS.append('-nostdinc')
+        for k, d in dirs:
+            CFLAGS.append('-i%s%s'%(k,d))
 
 # Enable 'PyObjC_STRICT_DEBUGGING' to enable some costly internal 
 # assertions. 
-CFLAGS=[
+CFLAGS.extend([
 
 # The following flags are an attempt at getting rid of /usr/local
 # in the compiler search path.
-#    "-nostdinc",
-#    "-isystem/usr/include",
-#    "-isystem/usr/lib/gcc/i686-apple-darwin9/4.0.1/include",
-#    "-iframework/System/Library/Frameworks",
-
     "-DPyObjC_STRICT_DEBUGGING",
     "-DMACOSX",
     "-no-cpp-precomp",
@@ -143,9 +179,10 @@
 
     # g5 optimized
     #"-fast", "-fPIC",
-    ]
+    ])
 
 
+BASE_LDFLAGS = []
 
 if not os.path.exists('/usr/include/objc/runtime.h'):
     CFLAGS.append('-DNO_OBJC2_RUNTIME')
@@ -154,6 +191,8 @@
     # Force compilation with the local SDK, compilation of PyObC will result in
     # a binary that runs on other releases of the OS without using a particular SDK.
     CFLAGS.extend(['-isysroot', '/'])
+    BASE_LDFLAGS.extend(['-isysroot', '/'])
+
 
 
 
@@ -173,7 +212,6 @@
 OBJC_LDFLAGS.extend(xml2config('--libs'))
 
 
-BASE_LDFLAGS = []
 
 CFLAGS.append('-Ibuild/codegen/')
 

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects