Index: Lib/distutils/tests/test_sysconfig.py =================================================================== --- Lib/distutils/tests/test_sysconfig.py (revision 72571) +++ Lib/distutils/tests/test_sysconfig.py (working copy) @@ -1,5 +1,6 @@ """Tests for distutils.sysconfig.""" import os +import test import unittest from distutils import sysconfig @@ -9,7 +10,13 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): + def setUp(self): + self.makefile = None + def tearDown(self): + if self.makefile is not None: + os.unlink(self.makefile) + def test_get_config_h_filename(self): config_h = sysconfig.get_config_h_filename() self.assert_(os.path.isfile(config_h), config_h) @@ -56,8 +63,32 @@ sysconfig.customize_compiler(comp) self.assertEquals(comp.exes['archiver'], 'my_ar -arflags') + def test_parse_makefile_base(self): + self.makefile = test.test_support.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': "'--arg1=optarg1' 'ENV=LIB'", + 'OTHER': 'foo'}) + def test_parse_makefile_literal_dollar(self): + self.makefile = test.test_support.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__': + test.test_support.run_unittest(test_suite()) Index: Lib/distutils/sysconfig.py =================================================================== --- Lib/distutils/sysconfig.py (revision 72571) +++ Lib/distutils/sysconfig.py (working copy) @@ -291,12 +293,16 @@ if m: n, v = m.group(1, 2) v = string.strip(v) - if "$" in v: + tmpv = v.replace("$$", "") # `$$' is a literal `$' in make + if "$" in tmpv: notdone[n] = v else: - try: v = int(v) - except ValueError: pass - done[n] = v + try: + v = int(v) + except ValueError: + done[n] = v.replace("$$", "$") # insert literal `$' + else: + done[n] = v # do variable interpolation here while notdone: