summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-09-15 00:03:13 (GMT)
committerGreg Ward <gward@python.net>2000-09-15 00:03:13 (GMT)
commit3fff8d2969f9b7298d12991432c9de45bf56357b (patch)
tree540d8a9da77100bc305f3e227e31147f528984d1 /Lib/distutils
parentf3d41272c6c5d576471f5c80108a96386bc51558 (diff)
downloadcpython-3fff8d2969f9b7298d12991432c9de45bf56357b.zip
cpython-3fff8d2969f9b7298d12991432c9de45bf56357b.tar.gz
cpython-3fff8d2969f9b7298d12991432c9de45bf56357b.tar.bz2
Fixed so 'parse_makefile()' uses the TextFile class to ensure that
comments are stripped and lines are joined according to the backslash convention.
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/sysconfig.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 3774ab2..27c08db 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -154,7 +154,7 @@ def parse_config_h(fp, g=None):
g[m.group(1)] = 0
return g
-def parse_makefile(fp, g=None):
+def parse_makefile(fn, g=None):
"""Parse a Makefile-style file.
A dictionary containing name/value pairs is returned. If an
@@ -162,15 +162,18 @@ def parse_makefile(fp, g=None):
used instead of a new dictionary.
"""
+ from distutils.text_file import TextFile
+ fp = TextFile(fn, strip_comments=1, join_lines=1)
+
if g is None:
g = {}
- variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n")
+ variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)")
done = {}
notdone = {}
- #
+
while 1:
line = fp.readline()
- if not line:
+ if line is None:
break
m = variable_rx.match(line)
if m:
@@ -233,7 +236,7 @@ def _init_posix():
# load the installed Makefile:
try:
filename = get_makefile_filename()
- file = open(filename)
+ parse_makefile(filename, g)
except IOError, msg:
my_msg = "invalid Python installation: unable to open %s" % filename
if hasattr(msg, "strerror"):
@@ -241,7 +244,6 @@ def _init_posix():
raise DistutilsPlatformError, my_msg
- parse_makefile(file, g)
# On AIX, there are wrong paths to the linker scripts in the Makefile
# -- these paths are relative to the Python source, but when installed