def test_no_compiler(self): # makes sure query_vcvarsall throws # a DistutilsPlatformError if the compiler # is not found from distutils2.msvccompiler import get_build_version if get_build_version() < 8.0: # this test is only for MSVC8.0 or above return from distutils2.msvc9compiler import query_vcvarsall def _find_vcvarsall(version): return None from distutils2 import msvc9compiler old_find_vcvarsall = msvc9compiler.find_vcvarsall msvc9compiler.find_vcvarsall = _find_vcvarsall try: self.assertRaises(DistutilsPlatformError, query_vcvarsall, 'wont find this version') finally: msvc9compiler.find_vcvarsall = old_find_vcvarsall
def test_reg_class(self): from distutils2.msvccompiler import get_build_version if get_build_version() < 8.0: # this test is only for MSVC8.0 or above return from distutils2.msvc9compiler import Reg self.assertRaises(KeyError, Reg.get_value, 'xxx', 'xxx') # looking for values that should exist on all # windows registeries versions. path = r'Control Panel\Desktop' v = Reg.get_value(path, u'dragfullwindows') self.assertTrue(v in (u'0', u'1', u'2')) import _winreg HKCU = _winreg.HKEY_CURRENT_USER keys = Reg.read_keys(HKCU, 'xxxx') self.assertEquals(keys, None) keys = Reg.read_keys(HKCU, r'Control Panel') self.assertTrue('Desktop' in keys)
try: import sysconfig except ImportError: from distutils2._backport import sysconfig # this keeps compatibility from 2.3 to 2.5 if sys.version < "2.6": USER_BASE = None HAS_USER_SITE = False else: from site import USER_BASE HAS_USER_SITE = True if os.name == 'nt': from distutils2.msvccompiler import get_build_version MSVC_VERSION = int(get_build_version()) # An extension name is just a dot-separated list of Python NAMEs (ie. # the same as a fully-qualified module name). extension_name_re = re.compile \ (r'^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$') def show_compilers (): from distutils2.compiler.ccompiler import show_compilers show_compilers() class build_ext(Command): description = "build C/C++ extensions (compile/link to build directory)"