我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用distutils.msvc9compiler.find_vcvarsall()。
def test_no_compiler(self): # makes sure query_vcvarsall raises # a DistutilsPlatformError if the compiler # is not found from distutils.msvc9compiler import query_vcvarsall def _find_vcvarsall(version): return None from distutils 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 patch_for_specialized_compiler(): """ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. Known supported compilers: -------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64); Microsoft Windows SDK 7.0 (x86, x64, ia64); Microsoft Windows SDK 6.1 (x86, x64, ia64) Microsoft Visual C++ 10.0: Microsoft Windows SDK 7.1 (x86, x64, ia64) Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) """ if platform.system() != 'Windows': # Compilers only availables on Microsoft Windows return if 'distutils' not in globals(): # The module isn't available to be patched return if unpatched: # Already patched return try: # Patch distutils.msvc9compiler unpatched['msvc9_find_vcvarsall'] = msvc9compiler.find_vcvarsall msvc9compiler.find_vcvarsall = msvc9_find_vcvarsall unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall msvc9compiler.query_vcvarsall = msvc9_query_vcvarsall except Exception: pass try: # Patch distutils._msvccompiler._get_vc_env unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env msvc14compiler._get_vc_env = msvc14_get_vc_env except Exception: pass
def msvc9_find_vcvarsall(version): """ Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython). Fall back to original behavior when the standalone compiler is not available. Redirect the path of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64) Parameters ---------- version: float Required Microsoft Visual C++ version. Return ------ vcvarsall.bat path: str """ Reg = msvc9compiler.Reg VC_BASE = r'Software\%sMicrosoft\DevDiv\VCForPython\%0.1f' key = VC_BASE % ('', version) try: # Per-user installs register the compiler path here productdir = Reg.get_value(key, "installdir") except KeyError: try: # All-user installs on a 64-bit system register here key = VC_BASE % ('Wow6432Node\\', version) productdir = Reg.get_value(key, "installdir") except KeyError: productdir = None if productdir: vcvarsall = os.path.os.path.join(productdir, "vcvarsall.bat") if os.path.isfile(vcvarsall): return vcvarsall return unpatched['msvc9_find_vcvarsall'](version)
def patch_for_msvc_specialized_compiler(): """ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. """ from . import msvc try: # Distutil file for MSVC++ 9.0 and upper (Python 2.7 to 3.4) import distutils.msvc9compiler as msvc9compiler except ImportError: pass try: # Distutil file for MSVC++ 14.0 and upper (Python 3.5+) import distutils._msvccompiler as msvc14compiler except ImportError: pass if platform.system() != 'Windows': # Compilers only availables on Microsoft Windows return if unpatched: # Already patched return try: # Patch distutils.msvc9compiler unpatched['msvc9_find_vcvarsall'] = msvc9compiler.find_vcvarsall msvc9compiler.find_vcvarsall = msvc.msvc9_find_vcvarsall unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall msvc9compiler.query_vcvarsall = msvc.msvc9_query_vcvarsall except NameError: pass try: # Patch distutils._msvccompiler._get_vc_env unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env msvc14compiler._get_vc_env = msvc.msvc14_get_vc_env except NameError: pass try: # Patch distutils._msvccompiler.gen_lib_options for Numpy unpatched['msvc14_gen_lib_options'] = msvc14compiler.gen_lib_options msvc14compiler.gen_lib_options = msvc.msvc14_gen_lib_options except NameError: pass
def patch_for_specialized_compiler(): """ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. Known supported compilers: -------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64); Microsoft Windows SDK 7.0 (x86, x64, ia64); Microsoft Windows SDK 6.1 (x86, x64, ia64) Microsoft Visual C++ 10.0: Microsoft Windows SDK 7.1 (x86, x64, ia64) Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) """ if platform.system() != 'Windows': # Compilers only availables on Microsoft Windows return if 'distutils' not in globals(): # The module isn't available to be patched return if unpatched: # Already patched return try: # Patch distutils.msvc9compiler unpatched['msvc9_find_vcvarsall'] = msvc9compiler.find_vcvarsall msvc9compiler.find_vcvarsall = msvc9_find_vcvarsall unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall msvc9compiler.query_vcvarsall = msvc9_query_vcvarsall except Exception: pass try: # Patch distutils._msvccompiler._get_vc_env unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env msvc14compiler._get_vc_env = msvc14_get_vc_env except Exception: pass try: # Patch distutils._msvccompiler.MSVCCompiler.library_dir_option unpatched['msvc14_library_dir_option'] = msvc14compiler.MSVCCompiler.library_dir_option msvc14compiler.MSVCCompiler.library_dir_option = msvc14_library_dir_option except Exception: pass
def patch_for_specialized_compiler(): """ Patch functions in distutils to use standalone Microsoft Visual C++ compilers. Known supported compilers: -------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64); Microsoft Windows SDK 7.0 (x86, x64, ia64); Microsoft Windows SDK 6.1 (x86, x64, ia64) Microsoft Visual C++ 10.0: Microsoft Windows SDK 7.1 (x86, x64, ia64) Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) """ if platform.system() != 'Windows': # Compilers only availables on Microsoft Windows return if 'distutils' not in globals(): # The module isn't available to be patched return if unpatched: # Already patched return try: # Patch distutils.msvc9compiler unpatched['msvc9_find_vcvarsall'] = msvc9compiler.find_vcvarsall msvc9compiler.find_vcvarsall = msvc9_find_vcvarsall unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall msvc9compiler.query_vcvarsall = msvc9_query_vcvarsall except NameError: pass try: # Patch distutils._msvccompiler._get_vc_env unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env msvc14compiler._get_vc_env = msvc14_get_vc_env except NameError: pass try: # Patch distutils._msvccompiler.gen_lib_options for Numpy unpatched['msvc14_gen_lib_options'] = msvc14compiler.gen_lib_options msvc14compiler.gen_lib_options = msvc14_gen_lib_options except NameError: pass