本文整理汇总了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
示例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()
示例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
示例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).
示例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("************************************************************")
示例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')
示例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