[Numpy-svn] r6359 - trunk/numpy/distutils/fcompiler

numpy-svn@scip... numpy-svn@scip...
Wed Feb 11 23:44:17 CST 2009


Author: stefan
Date: 2009-02-11 23:44:07 -0600 (Wed, 11 Feb 2009)
New Revision: 6359

Modified:
   trunk/numpy/distutils/fcompiler/gnu.py
Log:
Trust user's specification of MACOSX_DEPLOYMENT_TARGET [patch by Brian
Granger].

Modified: trunk/numpy/distutils/fcompiler/gnu.py
===================================================================
--- trunk/numpy/distutils/fcompiler/gnu.py	2009-02-12 04:22:03 UTC (rev 6358)
+++ trunk/numpy/distutils/fcompiler/gnu.py	2009-02-12 05:44:07 UTC (rev 6359)
@@ -87,21 +87,29 @@
     def get_flags_linker_so(self):
         opt = self.linker_so[1:]
         if sys.platform=='darwin':
-            # MACOSX_DEPLOYMENT_TARGET must be at least 10.3. This is
-            # a reasonable default value even when building on 10.4 when using
-            # the official Python distribution and those derived from it (when
-            # not broken).
             target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None)
-            if target is None or target == '':
-                target = '10.3'
-            major, minor = target.split('.')
-            if int(minor) < 3:
-                minor = '3'
-                warnings.warn('Environment variable '
-                    'MACOSX_DEPLOYMENT_TARGET reset to %s.%s' % (major, minor))
-            os.environ['MACOSX_DEPLOYMENT_TARGET'] = '%s.%s' % (major,
-                minor)
-
+            # If MACOSX_DEPLOYMENT_TARGET is set, we simply trust the value
+            # and leave it alone.  But, distutils will complain if the 
+            # environment's value is different from the one in the Python 
+            # Makefile used to build Python.  We let disutils handle this 
+            # error checking.
+            if not target:
+                # If MACOSX_DEPLOYMENT_TARGET is not set in the environment, 
+                # we try to get it first from the Python Makefile and then we 
+                # fall back to setting it to 10.3 to maximize the set of 
+                # versions we can work with.  This is a reasonable default
+                # even when using the official Python dist and those derived
+                # from it.
+                import distutils.sysconfig as sc
+                g = {}
+                filename = sc.get_makefile_filename()
+                sc.parse_makefile(filename, g)
+                target = g.get('MACOSX_DEPLOYMENT_TARGET', '10.3')
+                os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
+                if target == '10.3':
+                    s = 'Env. variable MACOSX_DEPLOYMENT_TARGET set to 10.3'
+                    warnings.warn(s)
+            
             opt.extend(['-undefined', 'dynamic_lookup', '-bundle'])
         else:
             opt.append("-shared")



More information about the Numpy-svn mailing list