]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 2975: when compiling multiple extension modules with visual studio 2008
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 2 Sep 2008 23:19:56 +0000 (23:19 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 2 Sep 2008 23:19:56 +0000 (23:19 +0000)
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.

Lib/distutils/msvc9compiler.py
Misc/NEWS

index c8d52c423754d7ef6316085c49b310e54923e4f6..0b27428d0515e6cd7d4c36574fb8191ffc252b01 100644 (file)
@@ -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())))
index 292edde9071471cc8597045e9a47206103c7ef2f..ff3b1b8cb6ccf0cab20692c508c8bb2fd0007d47 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -81,6 +81,10 @@ Library
 Extension Modules
 -----------------
 
+- Issue #2975: When compiling several extension modules with Visual Studio 2008
+  from the same python interpreter, some environment variables would grow
+  without limit.
+
 - Issue #3643: Added a few more checks to _testcapi to prevent segfaults by
   exploitation of poor argument checking.