New submission from Gregory Szorc:

distutils as of Python 2.7.9 is unable to locate vcvarsall.bat if Visual C++ 
Compiler for Python is the only Visual Studio "distribution" installed.

STR:

1) Do a fresh install of Windows + all updates
2) Install Microsoft Visual C++ Compiler for Python from 
http://www.microsoft.com/en-us/download/details.aspx?id=44266
3) Enter a Visual C++ 2008 command prompt via start menu 
4) Attempt to run any |python.exe setup.py| that contains C extensions
5) "Unable to find vcvarsall.bat"

Examining the behavior of MSVC for Python's bat scripts and filesystem layout, 
it is different enough from "full" "distributions" that it confused distutils.

First, MSVC for Python doesn't appear to set any meaningful registry entries. 
So, the registry checking in msvc9compiler fails to find anything.

Second, the command environment for MSVC for Python doesn't export 
VS90COMNTOOLS, so msvc9compiler has no clue where to go looking for files.

Third, even if VS90COMNTOOLS is set, msvc9compiler isn't able to find 
vcvarsall.bat because it is installed in %installdir%/vcvarsall.bat and not 
%installdir%/VC/vcvarsall.bat, unlike every other Visual Studio AFAICT.

Another concern is that distutils.msvc9compiler.find_vcvarsall() first attempts 
to read from the registry, not the environment. If you are in a MSVC for Python 
command shell and you also have Visual Studio 2008 installed, distutils will 
use vcvarsall.bat from the full Visual Studio installation instead of the 
Python one. I think this is wrong.

The MSVC for Python command prompt does have an environment variable that can 
be used: VCINSTALLDIR. It is set to %installdir%\VC\, which is equivalent to 
~/AppData/Local/Programs/Common/Microsoft/Visual C++ for Python/9.0/VC/ if you 
launch the installer with default options. distutils could be patched to find 
vcvarsall.bat in %VCINSTALLDIR%\..\vcvarsall.bat

Fortunately, a workaround is available:

1) Enter MSVC for Python command prompt
2) SET DISTUTILS_USE_SDK=1
3) SET MSSdk=1
4) python.exe setup.py ...

----------
components: Distutils
messages: 234110
nosy: Gregory.Szorc, dstufft, eric.araujo
priority: normal
severity: normal
status: open
title: distutils fails to locate vcvarsall with Visual C++ Compiler for Python
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23246>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to