diff options
author | David Cournapeau <cournape@gmail.com> | 2009-09-19 10:05:02 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2009-09-19 10:05:02 +0000 |
commit | 68179584d3277daaef57d079f82bb5976de9d5d1 (patch) | |
tree | b86a43d3ee3881fabf6aa56ca104be6ffb934d47 /numpy/distutils/npy_pkg_config.py | |
parent | aabe134c75bcbe7ba51cd0a14ff31aca489175b3 (diff) | |
download | numpy-68179584d3277daaef57d079f82bb5976de9d5d1.tar.gz |
Fix escaping backslash when parsing .ini files.
We need to escape them in variable substitution and interpolation to make it
work on windows where \ is the path separator.
Diffstat (limited to 'numpy/distutils/npy_pkg_config.py')
-rw-r--r-- | numpy/distutils/npy_pkg_config.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/numpy/distutils/npy_pkg_config.py b/numpy/distutils/npy_pkg_config.py index 2e42ee63a..75bc97185 100644 --- a/numpy/distutils/npy_pkg_config.py +++ b/numpy/distutils/npy_pkg_config.py @@ -55,6 +55,9 @@ def parse_flags(line): return d +def _escape_backslash(val): + return val.replace('\\', '\\\\') + class LibraryInfo(object): def __init__(self, name, description, version, sections, vars, requires=None): self.name = name @@ -71,10 +74,12 @@ class LibraryInfo(object): return self._sections.keys() def cflags(self, section="default"): - return self.vars.interpolate(self._sections[section]['cflags']) + val = self.vars.interpolate(self._sections[section]['cflags']) + return _escape_backslash(val) def libs(self, section="default"): - return self.vars.interpolate(self._sections[section]['libs']) + val = self.vars.interpolate(self._sections[section]['libs']) + return _escape_backslash(val) def __str__(self): m = ['Name: %s' % self.name] @@ -182,7 +187,7 @@ def parse_config(filename, dirs=None): vars = {} if config.has_section('variables'): for name, value in config.items("variables"): - vars[name] = value.replace("\\", "\\\\") + vars[name] = _escape_backslash(value) # Parse "normal" sections secs = [s for s in config.sections() if not s in ['meta', 'variables']] |