Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abcc3f4

Browse files
author
Tarek Ziadé
committed
Merged revisions 73341 via svnmerge from
svn+ssh://[email protected]/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 ........
1 parent 015c810 commit abcc3f4

3 files changed

Lines changed: 49 additions & 5 deletions

File tree

Lib/distutils/sysconfig.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,19 @@ def parse_makefile(fn, g=None):
286286
if m:
287287
n, v = m.group(1, 2)
288288
v = v.strip()
289-
if "$" in v:
289+
# `$$' is a literal `$' in make
290+
tmpv = v.replace('$$', '')
291+
292+
if "$" in tmpv:
290293
notdone[n] = v
291294
else:
292-
try: v = int(v)
293-
except ValueError: pass
294-
done[n] = v
295+
try:
296+
v = int(v)
297+
except ValueError:
298+
# insert literal `$'
299+
done[n] = v.replace('$$', '$')
300+
else:
301+
done[n] = v
295302

296303
# do variable interpolation here
297304
while notdone:

Lib/distutils/tests/test_sysconfig.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
"""Tests for distutils.sysconfig."""
22
import os
3+
import test
34
import unittest
45

56
from distutils import sysconfig
67
from distutils.ccompiler import get_default_compiler
78
from distutils.tests import support
8-
from test.support import TESTFN
9+
from test.support import TESTFN, run_unittest
910

1011
class SysconfigTestCase(support.EnvironGuard,
1112
unittest.TestCase):
13+
def setUp(self):
14+
super(SysconfigTestCase, self).setUp()
15+
self.makefile = None
16+
17+
def tearDown(self):
18+
if self.makefile is not None:
19+
os.unlink(self.makefile)
20+
super(SysconfigTestCase, self).tearDown()
1221

1322
def test_get_config_h_filename(self):
1423
config_h = sysconfig.get_config_h_filename()
@@ -56,8 +65,32 @@ def set_executables(self, **kw):
5665
sysconfig.customize_compiler(comp)
5766
self.assertEquals(comp.exes['archiver'], 'my_ar -arflags')
5867

68+
def test_parse_makefile_base(self):
69+
self.makefile = TESTFN
70+
fd = open(self.makefile, 'w')
71+
fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=LIB'" '\n')
72+
fd.write('VAR=$OTHER\nOTHER=foo')
73+
fd.close()
74+
d = sysconfig.parse_makefile(self.makefile)
75+
self.assertEquals(d, {'CONFIG_ARGS': "'--arg1=optarg1' 'ENV=LIB'",
76+
'OTHER': 'foo'})
77+
78+
def test_parse_makefile_literal_dollar(self):
79+
self.makefile = TESTFN
80+
fd = open(self.makefile, 'w')
81+
fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=\$$LIB'" '\n')
82+
fd.write('VAR=$OTHER\nOTHER=foo')
83+
fd.close()
84+
d = sysconfig.parse_makefile(self.makefile)
85+
self.assertEquals(d, {'CONFIG_ARGS': r"'--arg1=optarg1' 'ENV=\$LIB'",
86+
'OTHER': 'foo'})
87+
5988

6089
def test_suite():
6190
suite = unittest.TestSuite()
6291
suite.addTest(unittest.makeSuite(SysconfigTestCase))
6392
return suite
93+
94+
95+
if __name__ == '__main__':
96+
run_unittest(test_suite())

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,10 @@ Core and Builtins
772772
Library
773773
-------
774774

775+
- Issue #5201: distutils.sysconfig.parse_makefile() now understands `$$`
776+
in Makefiles. This prevents compile errors when using syntax like:
777+
`LDFLAGS='-rpath=\$$LIB:/some/other/path'`. Patch by Floris Bruynooghe.
778+
775779
- Issue #6131: test_modulefinder leaked when run after test_distutils.
776780
Patch by Hirokazu Yamamoto.
777781

0 commit comments

Comments
 (0)