diff options
author | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-06-11 08:26:40 (GMT) |
---|---|---|
committer | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-06-11 08:26:40 (GMT) |
commit | 6b16c00b926bf5e725cb41a4c48024bf324f23c2 (patch) | |
tree | 65f1149cb7e80e8d0915157417c64afa411718b7 /Lib/distutils | |
parent | e5ed650d711cdb47a9396dd236aebd57f7e1944d (diff) | |
download | cpython-6b16c00b926bf5e725cb41a4c48024bf324f23c2.zip cpython-6b16c00b926bf5e725cb41a4c48024bf324f23c2.tar.gz cpython-6b16c00b926bf5e725cb41a4c48024bf324f23c2.tar.bz2 |
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
........
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/sysconfig.py | 21 | ||||
-rw-r--r-- | Lib/distutils/tests/test_sysconfig.py | 23 |
2 files changed, 37 insertions, 7 deletions
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py index 615da07..6f99de2 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -275,18 +275,25 @@ def parse_makefile(fn, g=None): while 1: line = fp.readline() - if line is None: # eof + if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) - v = string.strip(v) - if "$" in v: + v = v.strip() + # `$$' 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: @@ -314,7 +321,7 @@ def parse_makefile(fn, g=None): else: try: value = int(value) except ValueError: - done[name] = string.strip(value) + done[name] = value.strip() else: done[name] = value del notdone[name] diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py index 9f82057..9f13952 100644 --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -2,11 +2,20 @@ from distutils import sysconfig import os +import test import unittest from test.test_support import TESTFN 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 = 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()) |