setuptools imports it and VERSION is 6 with a mingw Python. Move the version check to the actual compiler instance creation, which is also the only place where it's used. --- Python-3.7.3/Lib/distutils/msvc9compiler.py.orig 2019-03-25 21:21:05.000000000 +0100 +++ Python-3.7.3/Lib/distutils/msvc9compiler.py 2019-04-21 15:56:16.997090000 +0200 @@ -292,8 +292,6 @@ # More globals VERSION = get_build_version() -if VERSION < 8.0: - raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION) # MACROS = MacroExpander(VERSION) class MSVCCompiler(CCompiler) : @@ -328,6 +326,8 @@ def __init__(self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) + if VERSION < 8.0: + raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION) self.__version = VERSION self.__root = r"Software\Microsoft\VisualStudio" # self.__macros = MACROS