[TIP] Tox environment isolation and Windows SDK compilers

Paul Moore p.f.moore at gmail.com
Wed Dec 2 04:11:18 PST 2015

I just spent ages debugging a really annoying issue. I'm building my
code on Windows for 64-bit Python, using the SDK compilers. But for
some reason, my tests weren't finding the compilers.

After much frustration, I realised the problem. To use the SDK,
distutils looks for two environment variables, DISTUTILS_USE_SDK and
MSSdk. But tox now uses an isolated environment and doesn't pass those
variables on, so distutils can't find the right compiler :-(

I know there's TOX_TESTENV_PASSENV, which I'm using to work around the
issue, but would it be possible to add some sort of support for this
specific scenario? The distutils errors when you don't have the right
environment are utterly baffling.

Maybe detect DISTUTILS_USE_SDK in the environment, and if present add
DISTUTILS_USE_SDK, MSSdk, INCLUDE and LIB to the list of environment
variables passed through? (Those seem to be the minimum needed to get
things working)

Even if not, hopefully this post will help other people to work out
what's going wrong if they hit this issue. I added


into my environment before running tox, to work around the problem.


More information about the testing-in-python mailing list