我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用distutils.msvc9compiler.query_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_query_vcvarsall(ver, arch='x86', *args, **kwargs): """ Patched "distutils.msvc9compiler.query_vcvarsall" for support standalones compilers. Set environment without use of "vcvarsall.bat". 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) Parameters ---------- ver: float Required Microsoft Visual C++ version. arch: str Target architecture. Return ------ environment: dict """ # Try to get environement from vcvarsall.bat (Classical way) try: return unpatched['msvc9_query_vcvarsall'](ver, arch, *args, **kwargs) except distutils.errors.DistutilsPlatformError: # Pass error if Vcvarsall.bat is missing pass except ValueError: # Pass error if environment not set after executing vcvarsall.bat pass # If error, try to set environment directly try: return EnvironmentInfo(arch, ver).return_env() except distutils.errors.DistutilsPlatformError as exc: _augment_exception(exc, ver, arch) raise
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