[Python-Dev] msvccompiler and .NET sdk version

j w jwdevel at gmail.com
Sun Dec 16 03:40:26 CET 2007

Maybe this is fixed somewhere already, but just fyi:

I have the .NET sdk 2.0 installed (but not 1.1)
I'm running ActivePython 2.5.1

When I was building Mercurial from sources, I got this error:
    error: Python was built with Visual Studio 2003;
    extensions must be built with a compiler than can generate
compatible binaries.
    Visual Studio 2003 was not found on this system. If you have
Cygwin installed,
    you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

This is in spite of the fact that I had DISTUTILS_USE_SDK and MSSDK
set properly.

The problem was that msvccompiler.py was looking for
sdkinstallrootv1.1, and bailing when it couldn't be found.
I made a small change and it works fine for me now.
In load_macros, I put this:

if version > 7.0:
        self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
    except KeyError, exc:
        self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv2.0")

I had no problems with it - thought it might be useful for someone else.

I do however think that if I have DISTUTILS_USE_SDK set it shouldn't
be demanding registry entries of me in the first place.
But load_macros gets called in the constructor of MacroExpander before
the enclosing MSVCCompiler checks for the env vars, which seems not
quite right.

I don't use the VStuido installers so much, I just rearrange my
environment as needed so I'm used to being bitten by these registry
checks and such. For me, and other developers who need to switch
between toolsets (VC98, 2003, 2005, etc), running installers each time
that stomp on each others' registry entries and install different SDKs
is a major pain.
In this view of things, the original error message could be seen as
slightly misleading as well. I would say that Visual Studio 2003 could
in fact be found on my system, just not .NET sdk 1.1. If you ran the
installer there's no distinction, but in my case there is.


More information about the Python-Dev mailing list