當前位置: 首頁>>代碼示例>>Python>>正文


Python errors.CCompilerError方法代碼示例

本文整理匯總了Python中distutils.errors.CCompilerError方法的典型用法代碼示例。如果您正苦於以下問題:Python errors.CCompilerError方法的具體用法?Python errors.CCompilerError怎麽用?Python errors.CCompilerError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在distutils.errors的用法示例。


在下文中一共展示了errors.CCompilerError方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: construct_build_ext

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import CCompilerError [as 別名]
def construct_build_ext(build_ext):
    # This class allows extension building to fail.
    # https://stackoverflow.com/questions/41778153/
    ext_errors = (CCompilerError, DistutilsExecError,
                  DistutilsPlatformError, DistutilsError, IOError)
    class WrappedBuildExt(build_ext):
        def run(self):
            try:
                build_ext.run(self)
            except (DistutilsPlatformError, CompilerNotFound) as x:
                raise BuildFailed(x)

        def build_extension(self, ext):
            try:
                build_ext.build_extension(self, ext)
            except ext_errors as x:
                raise BuildFailed(x)
    return WrappedBuildExt 
開發者ID:dragonfly,項目名稱:dragonfly,代碼行數:20,代碼來源:setup.py

示例2: build_extension

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import CCompilerError [as 別名]
def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
            raise BuildFailed() 
開發者ID:maximdanilchenko,項目名稱:aiochclient,代碼行數:7,代碼來源:setup.py

示例3: _check_openmp_support

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import CCompilerError [as 別名]
def _check_openmp_support(self):
        # Compile a test program to determine if compiler supports OpenMP.
        _mkpath(self.build_temp)
        with stdchannel_redirected(sys.stderr, os.devnull):
            with _tempfile.NamedTemporaryFile(mode='w',
                                              dir=self.build_temp,
                                              prefix='openmptest',
                                              suffix='.c') as srcfile:
                _log.info("checking if compiler supports OpenMP")
                srcfile.write("""
                #include <omp.h>
                int testfunc() {
                    int i;
                    #pragma omp parallel for
                    for (i = 0; i < 10; i ++)
                        ;
                    return omp_get_num_threads();
                }
                """)
                srcfile.flush()
                try:
                    objects = self.compiler.compile([srcfile.name],
                                                    extra_postargs=["-fopenmp"],
                                                    output_dir="/")
                except _CCompilerError:
                    _log.info("compiler does not support OpenMP")
                    use_openmp = False
                else:
                    _log.info("enabling OpenMP support")
                    use_openmp = True
                    for o in objects:
                        os.remove(o)
            return use_openmp 
開發者ID:hpclab,項目名稱:rankeval,代碼行數:35,代碼來源:setup.py

示例4: build_extension

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import CCompilerError [as 別名]
def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except (CCompilerError, CompileError, DistutilsExecError) as e:
            self._unavailable(e)
            self.extensions = []  # avoid copying missing files (it would fail). 
開發者ID:fossasia,項目名稱:knitlib,代碼行數:8,代碼來源:setup.py

示例5: build_extension

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import CCompilerError [as 別名]
def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
            print("************************************************************")
            print("Cannot compile C accelerator module, use pure python version")
            print("************************************************************") 
開發者ID:sdispater,項目名稱:pendulum,代碼行數:9,代碼來源:build.py

示例6: refuse_compilation

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import CCompilerError [as 別名]
def refuse_compilation(self, *args, **kwargs):
        """Refuse compilation"""
        raise CCompilerError('Compiling extensions is not supported on Jython') 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:5,代碼來源:jythoncompiler.py

示例7: get_c_extension_status

# 需要導入模塊: from distutils import errors [as 別名]
# 或者: from distutils.errors import CCompilerError [as 別名]
def get_c_extension_status(libraries=['R'], include_dirs=None,
                           library_dirs=None):
    c_code = ('#include <Rinterface.h>\n\n'
              'int main(int argc, char **argv) { return 0; }')
    tmp_dir = tempfile.mkdtemp(prefix='tmp_pw_r_')
    bin_file = os.path.join(tmp_dir, 'test_pw_r')
    src_file = bin_file + '.c'
    with open(src_file, 'w') as fh:
        fh.write(c_code)

    compiler = new_compiler()
    customize_compiler(compiler)
    try:
        compiler.link_executable(
            compiler.compile([src_file], output_dir=tmp_dir,
                             include_dirs=include_dirs),
            bin_file,
            libraries=libraries,
            library_dirs=library_dirs)
    except CCompilerError as cce:
        status = COMPILATION_STATUS.COMPILE_ERROR
        print(cce)
    except DistutilsExecError as dee:
        status = COMPILATION_STATUS.NO_COMPILER
        print(dee)
    except DistutilsPlatformError as dpe:
        status = COMPILATION_STATUS.PLATFORM_ERROR
        print(dpe)
    else:
        status = COMPILATION_STATUS.OK
    shutil.rmtree(tmp_dir)
    return status 
開發者ID:rpy2,項目名稱:rpy2,代碼行數:34,代碼來源:setup.py


注:本文中的distutils.errors.CCompilerError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。