]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 73343 via svnmerge from
authorTarek Ziadé <ziade.tarek@gmail.com>
Thu, 11 Jun 2009 08:35:26 +0000 (08:35 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Thu, 11 Jun 2009 08:35:26 +0000 (08:35 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r73343 | tarek.ziade | 2009-06-11 10:31:17 +0200 (Thu, 11 Jun 2009) | 9 lines

  Merged revisions 73341 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r73341 | tarek.ziade | 2009-06-11 10:12:20 +0200 (Thu, 11 Jun 2009) | 1 line

    Fixed #5201: now distutils.sysconfig.parse_makefile() understands '53264' in Makefiles
  ........
................

Lib/distutils/sysconfig.py
Lib/distutils/tests/test_sysconfig.py
Misc/NEWS

index 466194cd3fca7dcc7525bdc2275c970b3e99c304..eee9746d77a000fa002738996c98a32d1c128be7 100644 (file)
@@ -276,12 +276,19 @@ def parse_makefile(fn, g=None):
         if m:
             n, v = m.group(1, 2)
             v = v.strip()
-            if "$" in v:
+            # `$$' is a literal `$' in make
+            tmpv = v.replace('$$', '')
+
+            if "$" in tmpv:
                 notdone[n] = v
             else:
-                try: v = int(v)
-                except ValueError: pass
-                done[n] = v
+                try:
+                    v = int(v)
+                except ValueError:
+                    # insert literal `$'
+                    done[n] = v.replace('$$', '$')
+                else:
+                    done[n] = v
 
     # do variable interpolation here
     while notdone:
index 1934abaf960857a335178d1fa81156bb436506a0..3b32de946d7fe17abce0ff83935d1c7a925ef931 100644 (file)
@@ -2,11 +2,20 @@
 
 from distutils import sysconfig
 import os
+import test
 import unittest
 
-from test.support import TESTFN
+from test.support import TESTFN, run_unittest
 
 class SysconfigTestCase(unittest.TestCase):
+    def setUp(self):
+        super(SysconfigTestCase, self).setUp()
+        self.makefile = None
+
+    def tearDown(self):
+        if self.makefile is not None:
+            os.unlink(self.makefile)
+        super(SysconfigTestCase, self).tearDown()
 
     def test_get_config_h_filename(self):
         config_h = sysconfig.get_config_h_filename()
@@ -51,8 +60,22 @@ class SysconfigTestCase(unittest.TestCase):
         self.assert_(isinstance(cvars, dict))
         self.assert_(cvars)
 
+    def test_parse_makefile_literal_dollar(self):
+        self.makefile = TESTFN
+        fd = open(self.makefile, 'w')
+        fd.write(r"CONFIG_ARGS=  '--arg1=optarg1' 'ENV=\$$LIB'" '\n')
+        fd.write('VAR=$OTHER\nOTHER=foo')
+        fd.close()
+        d = sysconfig.parse_makefile(self.makefile)
+        self.assertEquals(d, {'CONFIG_ARGS': r"'--arg1=optarg1' 'ENV=\$LIB'",
+                              'OTHER': 'foo'})
+
 
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(SysconfigTestCase))
     return suite
+
+
+if __name__ == '__main__':
+    run_unittest(test_suite())
index 94e074d86293965b66ef701675f413562f83a296..e2bb2f3ba50199c6722fe295286348fc47c576e6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -323,6 +323,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #5201: distutils.sysconfig.parse_makefile() now understands `$$`
+  in Makefiles. This prevents compile errors when using syntax like:
+  `LDFLAGS='-rpath=\$$LIB:/some/other/path'`. Patch by Floris Bruynooghe.
+
 - Issue #6062: In distutils, fixed the package option of build_ext. Feedback 
   and tests on pywin32 by Tim Golden.