VS8 include dirs grow without bound

I tracked down a testing failure for Cython tests on the Windows platform to be the result of how the Visual C environment variables are being detected. In the function, query_vcvarsall, the .bat file: "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" is being run with the arguments: x86 & set This in turn calls the platform-specific file vcvars32.bat (or other). In this file, the PATH, INCLUDE, and LIBPATH environment variables are simply being appended/prepended with their values. initialize() then just overrides the os.environ values with these monotonically growing variables. It seems that duplicate names should be filtered out from these paths to prevent overflow. The attached patch seems to fix this issue, if a bit brute force. Please review as a candidate. ===== @set PATH=%DevEnvDir%;%VCINSTALLDIR%\BIN;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%Framework35Version%\Microsoft .NET Framework 3.5 (Pre-Release Version);%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\VCPackages;%PATH% @set INCLUDE=%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%INCLUDE% @set LIB=%VCINSTALLDIR%\ATLMFC\LIB;%VCINSTALLDIR%\LIB;%LIB% @set LIBPATH=%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\ATLMFC\LIB;%VCINSTALLDIR%\LIB;%LIBPATH% ===== --- msvc9compiler.py.orig 2008-05-26 12:29:18.529288200 -0700 +++ msvc9compiler.py 2008-05-26 12:34:11.403841800 -0700 @@ -193,6 +193,17 @@ 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 @@ -257,7 +268,7 @@ 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())))

On Mon, May 26, 2008 at 2:48 PM, Jim Kleckner <jek-gmane@kleckner.net> wrote:
I tracked down a testing failure for Cython tests on the Windows platform to be the result of how the Visual C environment variables are being detected.
Please put this (and it's patch) on the bug tracker: http://bugs.python.org -- Cheers, Benjamin Peterson "There's no place like 127.0.0.1."

Jim Kleckner wrote: ...
initialize() then just overrides the os.environ values with these monotonically growing variables.
It seems that duplicate names should be filtered out from these paths to prevent overflow.
The attached patch seems to fix this issue, if a bit brute force. Please review as a candidate.
I created the following tracker item for this: http://bugs.python.org/issue2975
participants (2)
-
Benjamin Peterson
-
Jim Kleckner