diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-09-02 23:19:56 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-09-02 23:19:56 (GMT) |
commit | 293924bf31887d88130f8769d4dbaac878db13fd (patch) | |
tree | 83da711ba86d62fae50cd5e326c8adc05be905e2 /Lib/distutils | |
parent | 042025f6b8616f1d505cec1122bebc01e7083e69 (diff) | |
download | cpython-293924bf31887d88130f8769d4dbaac878db13fd.zip cpython-293924bf31887d88130f8769d4dbaac878db13fd.tar.gz cpython-293924bf31887d88130f8769d4dbaac878db13fd.tar.bz2 |
Issue 2975: when compiling multiple extension modules with visual studio 2008
from the same python instance, some environment variables (LIB, INCLUDE)
would grow without limit.
Tested with these statements:
distutils.ccompiler.new_compiler().initialize()
print os.environ['LIB']
But I don't know how to turn them into reliable unit tests.
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/msvc9compiler.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py index c8d52c4..0b27428 100644 --- a/Lib/distutils/msvc9compiler.py +++ b/Lib/distutils/msvc9compiler.py @@ -193,6 +193,17 @@ def normalize_and_reduce_paths(paths): reduced_paths.append(np) return reduced_paths +def removeDuplicates(variable): + """Remove duplicate values of an environment variable. + """ + oldList = variable.split(os.pathsep) + newList = [] + for i in oldList: + if i not in newList: + newList.append(i) + newVariable = os.pathsep.join(newList) + return newVariable + def find_vcvarsall(version): """Find the vcvarsall.bat file @@ -252,12 +263,12 @@ def query_vcvarsall(version, arch="x86"): if '=' not in line: continue line = line.strip() - key, value = line.split('=') + key, value = line.split('=', 1) key = key.lower() if key in interesting: if value.endswith(os.pathsep): value = value[:-1] - result[key] = value + result[key] = removeDuplicates(value) if len(result) != len(interesting): raise ValueError(str(list(result.keys()))) |