[Python-checkins] r83066 - in python/branches/py3k/Lib/distutils: sysconfig.py tests/test_sysconfig.py

ronald.oussoren python-checkins at python.org
Fri Jul 23 11:43:17 CEST 2010


Author: ronald.oussoren
Date: Fri Jul 23 11:43:17 2010
New Revision: 83066

Log:
Ensure that the Makefile variable expansion
in distutils.sysconfig matches that in the 
toplevel sysconfig module.

Without this patch universal builds on OSX are
broken.

Als add a test that checks that the two version
of get_config_vars agree on important values.


Modified:
   python/branches/py3k/Lib/distutils/sysconfig.py
   python/branches/py3k/Lib/distutils/tests/test_sysconfig.py

Modified: python/branches/py3k/Lib/distutils/sysconfig.py
==============================================================================
--- python/branches/py3k/Lib/distutils/sysconfig.py	(original)
+++ python/branches/py3k/Lib/distutils/sysconfig.py	Fri Jul 23 11:43:17 2010
@@ -300,6 +300,12 @@
                 else:
                     done[n] = v
 
+    # Variables with a 'PY_' prefix in the makefile. These need to
+    # be made available without that prefix through sysconfig.
+    # Special care is needed to ensure that variable expansion works, even
+    # if the expansion uses the name without a prefix.
+    renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS')
+
     # do variable interpolation here
     while notdone:
         for name in list(notdone):
@@ -316,6 +322,16 @@
                 elif n in os.environ:
                     # do it like make: fall back to environment
                     item = os.environ[n]
+
+                elif n in renamed_variables:
+                    if name.startswith('PY_') and name[3:] in renamed_variables:
+                        item = ""
+
+                    elif 'PY_' + n in notdone:
+                        found = False
+
+                    else:
+                        item = str(done['PY_' + n])
                 else:
                     done[n] = item = ""
                 if found:
@@ -330,6 +346,13 @@
                         else:
                             done[name] = value
                         del notdone[name]
+
+                        if name.startswith('PY_') \
+                            and name[3:] in renamed_variables:
+
+                            name = name[3:]
+                            if name not in done:
+                                done[name] = value
             else:
                 # bogus variable reference; just drop it since we can't deal
                 del notdone[name]

Modified: python/branches/py3k/Lib/distutils/tests/test_sysconfig.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_sysconfig.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_sysconfig.py	Fri Jul 23 11:43:17 2010
@@ -93,6 +93,15 @@
                               'OTHER': 'foo'})
 
 
+    def test_sysconfig_module(self):
+        import sysconfig as global_sysconfig
+        self.assertEquals(global_sysconfig.get_config_var('CFLAGS'), sysconfig.get_config_var('CFLAGS'))
+        self.assertEquals(global_sysconfig.get_config_var('LDFLAGS'), sysconfig.get_config_var('LDFLAGS'))
+        self.assertEquals(global_sysconfig.get_config_var('LDSHARED'),sysconfig.get_config_var('LDSHARED'))
+        self.assertEquals(global_sysconfig.get_config_var('CC'), sysconfig.get_config_var('CC'))
+
+
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(SysconfigTestCase))


More information about the Python-checkins mailing list