This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Distutils and Windows SDK 7.1
Type: enhancement Stage:
Components: Distutils, Windows Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: JGoutin, dstufft, eric.araujo, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2015-11-17 10:31 by JGoutin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
msvc9compiler.py JGoutin, 2015-11-19 11:17 Initial commit: Add automatic compatibility for Windows SDK 7.1 + some cleaning and PEP8 on file
msvc9compiler.py JGoutin, 2015-11-20 11:05 Update 1: Set "libpath" Env var as optional result
msvc9compiler.py JGoutin, 2015-11-20 15:07 Update 2: Cross-compilation arguments for SetEnv.Cmd
Messages (8)
msg254788 - (view) Author: J.Goutin (JGoutin) * Date: 2015-11-17 10:31
Hello,

This issue is related to Visual C++ standalone distributions (Without any Visual Studio version installed).

Distutils don't properly detect theses compilers. It try to work with "vcvarsall.bat" but this file : 
- is missing with Visual C++ Build Tools 2015.
- don't set correctly the environment with Windows SDK 7.0/7.1

I fixed this issue by modifying "vcvarsall.bat" for redirect to the goods files and set properly the environment. The procedure is detailed here : https://wiki.python.org/moin/WindowsCompilers

I have tested this issue with :
- Python 3.5 + Visual C++ Tools 2015
- Python 3.4 + Windows SDK 7.1
I have not tested yet (But it work exactly as SDK 7.1): 
- Python 2.7 + Windows SDK 7.0


I can eventually work to fix this directly on distutils (Or help to fix it).
msg254802 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-11-17 15:36
The tools for VS 2015 is a known issue. I let the team know before they released it but it was too late. There'll be an update soon that should work.

For Python 3.2 and earlier use http://aka.ms/vcpython27 and setuptools 6 or later.

The SDK 7.1 layout doesn't match what distutils expects, so it requires more changes than simple detection. The recommendation is to use the SDK command prompt and set DISTUTILS_USE_SDK=1 before building wheels. (There may be one more env var needed here, I'm on my phone and can't check.)
msg254810 - (view) Author: J.Goutin (JGoutin) * Date: 2015-11-17 18:18
For SDK 7.1, with "DISTUTILS_USE_SDK=1" (And "MSSdk=1"), I still have the problem.

The error is on "include", "lib", "libpath", "path" environment variables which are not set by "vcvarsall.bat" (And are difficult to set manually). I looked on "msvc9compiler.py" file, I see that DISTUTILS_USE_SDK set the names for some compiler executables but not these variables.

A solution should be to call "SetEnv.cmd" in place of "vcvarsall.bat" if SDK is installed and if environment variables listed above are missing even after the call of "vcvarsall.bat" (Or if "vcvarsall.bat" is missing).
"SetEnv.cmd" properly set the environment and I successfully compiled files after launched it.

I can do this change and commit it. This will add fully automatic compatibility for SDK 6.1/7.0/7.1, so all possibles version for VC++2008 and 2010 (Is it also possible to add "vcbuildtools.bat" for VC++ Build Tools 2015, but you say it's already fixed for it.)
msg254894 - (view) Author: J.Goutin (JGoutin) * Date: 2015-11-19 11:17
Hello,

I modified "msvc9compiler.py" with following changes : 

- Add automatic compatibility with standalone VC++ compilers from Windows SDK 7.1. (Not for 6.1/7.0, because that finally don't work as good as it seem on first view and there is already MSVC++ for Python 2.7).
- Changed error when "include", "lib", "libpath" or "path" environment variable is missing to be more clear.
- Modified some comments and strings to not specify exclusively VS2008 (This file is also compatible with more recent VS and that was not really clear before)
- Remove "gen_preprocess_options" from import because it was unused.
- Fixed PEP8.

The file was tested with SDK7.1 on a Cython compilation + a Pip install from source on Python 3.4 and seem to work perfectly.

Ps: Forget my previous comment on VS2015, I didn't see that code for it was moved on "_msvccompiler.py". I'll wait the official release for the fix on Visual C++ Build Tools 2015 (Which is, anyway, only in technical preview since october)
msg254965 - (view) Author: J.Goutin (JGoutin) * Date: 2015-11-20 11:05
I updated the file.

I did some new tests with cross compilation and I see that the "libpath" environment variable may be missing in some case.
Fortunately, this one is not used in the following of the code. So I set it as optional result for "query_vcvarsall".
msg254987 - (view) Author: J.Goutin (JGoutin) * Date: 2015-11-20 15:07
Better compatibility for Architectures names conversion between Vcvarsall.bat and SetEnv.Cmd for cross compilation.

This seem to work good on classic compilation, but I still have difficulties with cross-compilation.
msg254999 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-11-20 16:59
I appreciate the enthusiasm, but be aware that at best this will show up in Python 3.4.4 only, and the timeline for that is very short.

You would have a better chance if you were to make this a monkey-patch via setuptools. See https://bitbucket.org/pypa/setuptools/src/tip/setuptools/msvc9_support.py for where we added this for the compiler for 2.7.
msg255141 - (view) Author: J.Goutin (JGoutin) * Date: 2015-11-23 09:17
OK, I'll look that.
History
Date User Action Args
2022-04-11 14:58:23adminsetgithub: 69832
2015-11-23 09:17:04JGoutinsetstatus: open -> closed
resolution: out of date
messages: + msg255141
2015-11-20 16:59:43steve.dowersetmessages: + msg254999
2015-11-20 15:07:02JGoutinsetfiles: + msvc9compiler.py

messages: + msg254987
title: Distutils and Windows SDK 7.0 / Windows SDK 7.1 / Visual C++ Build Tools 2015 -> Distutils and Windows SDK 7.1
2015-11-20 11:05:40JGoutinsetfiles: + msvc9compiler.py

messages: + msg254965
2015-11-19 11:17:57JGoutinsetfiles: + msvc9compiler.py

messages: + msg254894
versions: + Python 3.3, Python 3.4, - Python 2.7, Python 3.5, Python 3.6
2015-11-17 18:18:01JGoutinsetmessages: + msg254810
2015-11-17 15:36:18steve.dowersetmessages: + msg254802
2015-11-17 14:38:57r.david.murraysetnosy: + paul.moore, tim.golden, zach.ware, steve.dower

components: + Windows
versions: - Python 3.2, Python 3.3, Python 3.4
2015-11-17 10:31:43JGoutincreate