当前位置: 首页>>代码示例>>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;未经允许,请勿转载。