summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-06-11 08:31:17 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-06-11 08:31:17 (GMT)
commitabcc3f4357529de91109fa52cd2fff67b13a44b0 (patch)
tree40efadbc2d3a521c0dba9817a3965ccf8e227546 /Lib
parent015c8103b1447f3914106de1522fa16ee5ed04b6 (diff)
downloadcpython-abcc3f4357529de91109fa52cd2fff67b13a44b0.zip
cpython-abcc3f4357529de91109fa52cd2fff67b13a44b0.tar.gz
cpython-abcc3f4357529de91109fa52cd2fff67b13a44b0.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')
-rw-r--r--Lib/distutils/sysconfig.py15
-rw-r--r--Lib/distutils/tests/test_sysconfig.py35
2 files changed, 45 insertions, 5 deletions
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 223ff67..0fbd541 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -286,12 +286,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:
diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py
index 322df39..2d8fa27 100644
--- a/Lib/distutils/tests/test_sysconfig.py
+++ b/Lib/distutils/tests/test_sysconfig.py
@@ -1,14 +1,23 @@
"""Tests for distutils.sysconfig."""
import os
+import test
import unittest
from distutils import sysconfig
from distutils.ccompiler import get_default_compiler
from distutils.tests import support
-from test.support import TESTFN
+from test.support import TESTFN, run_unittest
class SysconfigTestCase(support.EnvironGuard,
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()
@@ -56,8 +65,32 @@ class SysconfigTestCase(support.EnvironGuard,
sysconfig.customize_compiler(comp)
self.assertEquals(comp.exes['archiver'], 'my_ar -arflags')
+ def test_parse_makefile_base(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': "'--arg1=optarg1' 'ENV=LIB'",
+ 'OTHER': 'foo'})
+
+ 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())