classification
Title: setup.py cannot find vcversall.bat on MSWin 8.1 if installed in user AppData
Type: behavior Stage: resolved
Components: Distutils, Windows Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: distutils fails to locate vcvarsall with Visual C++ Compiler for Python
View: 23246
Assigned To: Nosy List: dstufft, eric.araujo, jyrkih, laranzu, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2017-11-03 10:44 by laranzu, last changed 2017-11-04 23:25 by laranzu. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4249 closed laranzu, 2017-11-03 21:45
Messages (3)
msg305470 - (view) Author: Hugh Fisher (laranzu) * Date: 2017-11-03 10:44
This was raised in issue #23246 but apparently not addressed at the time.

The Visual C for Python 2.7 tools on my MS Windows 8.1 system installed themselves under the invisible AppData directory because I did not do so as Administrator. Running setup.py to build a (2.7) native extension then fails because it can't find VCVERSALL.BAT.

Fix is a couple of extra lines in find_vcvarsall in msvc9compiler.py to search under AppData if it can't be found in the system location. I will submit a pull request.
msg305566 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-11-04 21:40
Duplicate of issue23246. AFAIK, nothing has changed since then.

The PR in its current form is not acceptable - there is a totally reliable registry key for finding the compiler, which is better than guessing a path. See the code in setuptools (and also make the case for why we should help people to build extensions without the fixes provided by setuptools, but do it on the existing issue).
msg305577 - (view) Author: Hugh Fisher (laranzu) * Date: 2017-11-04 23:25
The registry key is not totally reliable for finding the compiler.

What I did: my system is Windows 8.1 64 bit with Python 2.7 64 bit installed. I'd been testing a setup.py on Linux, time to try on MSWin. So I downloaded VCForPython27.msi as recommended by the Python docs, ran it, tried python setup.py build_ext. Failed because could not find VCVARSALL.BAT. Standard MSWin troubleshooting first step: restart. Still no.

Search turned up a freshly installed dir under AppData. After searching through distutils code, stepping through it, and poking around with RegEdit it turned out that while my system has various registry keys for Visual Studio versions from 7.1 through 12.0, even keys for 9.0, but not the particular one that find_vcvarsall wants.

Why not? How can I know? I added two lines of code to msvc9compiler.py and my extension now compiled.

To me, only the file system can be a totally reliable guide as to whether a particular path exists. I agree that it's not practical to wildly guess, or to search everywhere. But this is for Python 2.7, where the configuration has been frozen for all time. There's only a couple of places these files could be.

The additional code I've proposed will make Python continue to work even if the registry is clobbered. It will also make Python continue to work if the user copies the files from another system instead of running the installer. I think this is worthwhile, so ask that you reopen this issue.
History
Date User Action Args
2017-11-04 23:25:53laranzusetmessages: + msg305577
2017-11-04 21:40:03steve.dowersetstatus: open -> closed
superseder: distutils fails to locate vcvarsall with Visual C++ Compiler for Python
messages: + msg305566

resolution: duplicate
stage: patch review -> resolved
2017-11-03 21:45:32laranzusetkeywords: + patch
stage: patch review
pull_requests: + pull_request4227
2017-11-03 17:12:46skrahlinkissue28706 superseder
2017-11-03 17:12:10skrahsetnosy: + jyrkih
2017-11-03 15:00:35zach.waresetnosy: + paul.moore, tim.golden, zach.ware, steve.dower
components: + Windows
2017-11-03 10:44:13laranzucreate