python compile error_Python errors.CompileError方法代码示例

本文整理汇总了Python中distutils.errors.CompileError方法的典型用法代码示例。如果您正苦于以下问题:Python errors.CompileError方法的具体用法?Python errors.CompileError怎么用?Python errors.CompileError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块distutils.errors的用法示例。

在下文中一共展示了errors.CompileError方法的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _compile_cu

​点赞 6

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def _compile_cu(self, sources, output_dir=None, macros=None,

include_dirs=None, debug=0, extra_preargs=None,

extra_postargs=None, depends=None):

# Compile CUDA C files, mainly derived from UnixCCompiler._compile().

macros, objects, extra_postargs, pp_opts, _build = \

self._setup_compile(output_dir, macros, include_dirs, sources,

depends, extra_postargs)

compiler_so = CUDA['nvcc']

cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)

post_args = CUDA['post_args']

for obj in objects:

try:

src, _ = _build[obj]

except KeyError:

continue

try:

self.spawn([compiler_so] + cc_args + [src, '-o', obj] + post_args)

except errors.DistutilsExecError as e:

raise errors.CompileError(str(e))

return objects

开发者ID:benfred,项目名称:implicit,代码行数:25,

示例2: get_ethtool_macro

​点赞 6

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def get_ethtool_macro():

# see: https://github.com/giampaolo/psutil/issues/659

from distutils.unixccompiler import UnixCCompiler

from distutils.errors import CompileError

with tempfile.NamedTemporaryFile(

suffix='.c', delete=False, mode="wt") as f:

f.write("#include ")

output_dir = tempfile.mkdtemp()

try:

compiler = UnixCCompiler()

# https://github.com/giampaolo/psutil/pull/1568

if os.getenv('CC'):

compiler.set_executable('compiler_so', os.getenv('CC'))

with silenced_output('stderr'):

with silenced_output('stdout'):

compiler.compile([f.name], output_dir=output_dir)

except CompileError:

return ("PSUTIL_ETHTOOL_MISSING_TYPES", 1)

else:

return None

finally:

os.remove(f.name)

shutil.rmtree(output_dir)

开发者ID:giampaolo,项目名称:psutil,代码行数:27,

示例3: UnixCCompiler__compile

​点赞 6

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):

"""Compile a single source files with a Unix-style compiler."""

# HP ad-hoc fix, see ticket 1383

ccomp = self.compiler_so

if ccomp[0] == 'aCC':

# remove flags that will trigger ANSI-C mode for aCC

if '-Ae' in ccomp:

ccomp.remove('-Ae')

if '-Aa' in ccomp:

ccomp.remove('-Aa')

# add flags for (almost) sane C++ handling

ccomp += ['-AA']

self.compiler_so = ccomp

display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src)

try:

self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +

extra_postargs, display = display)

except DistutilsExecError:

msg = str(get_exception())

raise CompileError(msg)

开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,

示例4: get_cpp_flags

​点赞 6

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def get_cpp_flags(build_ext):

last_err = None

default_flags = ['-std=c++11', '-fPIC', '-O2']

if sys.platform == 'darwin':

# Darwin most likely will have Clang, which has libc++.

flags_to_try = [default_flags + ['-stdlib=libc++'], default_flags]

else:

flags_to_try = [default_flags, default_flags + ['-stdlib=libc++']]

for cpp_flags in flags_to_try:

try:

test_compile(build_ext, 'test_cpp_flags', extra_preargs=cpp_flags,

code=textwrap.dedent('''\

#include

void test() {

}

'''))

return cpp_flags

except (CompileError, LinkError):

last_err = 'Unable to determine C++ compilation flags (see error above).'

except Exception:

last_err = 'Unable to determine C++ compilation flags. ' \

'Last error:\n\n%s' % traceback.format_exc()

raise DistutilsPlatformError(last_err)

开发者ID:mlperf,项目名称:training_results_v0.6,代码行数:27,

示例5: get_tf_libs

​点赞 6

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def get_tf_libs(build_ext, lib_dirs, cpp_flags):

last_err = None

for tf_libs in [['tensorflow_framework'], []]:

try:

lib_file = test_compile(build_ext, 'test_tensorflow_libs',

library_dirs=lib_dirs, libraries=tf_libs,

extra_preargs=cpp_flags,

code=textwrap.dedent('''\

void test() {

}

'''))

from tensorflow.python.framework import load_library

load_library.load_op_library(lib_file)

return tf_libs

except (CompileError, LinkError):

last_err = 'Unable to determine -l link flags to use with TensorFlow (see error above).'

except Exception:

last_err = 'Unable to determine -l link flags to use with TensorFlow. ' \

'Last error:\n\n%s' % traceback.format_exc()

raise DistutilsPlatformError(last_err)

开发者ID:mlperf,项目名称:training_results_v0.6,代码行数:25,

示例6: has_flag

​点赞 6

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def has_flag(compiler, flagname, output_dir=None):

# see https://bugs.python.org/issue26689

"""Return a boolean indicating whether a flag name is supported on

the specified compiler.

"""

with tempfile.NamedTemporaryFile('w', suffix='.c', delete=False) as f:

f.write('int main (int argc, char **argv) { return 0; }')

f.close()

try:

obj = compiler.compile([f.name], output_dir=output_dir,

extra_postargs=[flagname])

os.remove(*obj)

except CompileError:

return False

finally:

os.remove(f.name)

return True

开发者ID:dkriegner,项目名称:xrayutilities,代码行数:19,

示例7: prevent_msvc_compiling_patch

​点赞 6

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def prevent_msvc_compiling_patch(): # type: ignore

import distutils

import distutils._msvccompiler

import distutils.msvc9compiler

import distutils.msvccompiler

from distutils.errors import CompileError

def raise_compile_error(*args, **kwargs): # type: ignore

raise CompileError('Chalice blocked C extension compiling.')

distutils._msvccompiler.MSVCCompiler.compile = raise_compile_error

distutils.msvc9compiler.MSVCCompiler.compile = raise_compile_error

distutils.msvccompiler.MSVCCompiler.compile = raise_compile_error

# This is the setuptools shim used to execute setup.py by pip.

# Lines 2 and 3 have been added to call the above function

# `prevent_msvc_compiling_patch` and extra escapes have been added on line

# 5 because it is passed through another layer of string parsing before it

# is executed.

开发者ID:aws,项目名称:chalice,代码行数:21,

示例8: _compile

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):

if ext == '.rc' or ext == '.res':

# gcc needs '.res' and '.rc' compiled to object files !!!

try:

self.spawn(["windres", "-i", src, "-o", obj])

except DistutilsExecError, msg:

raise CompileError, msg

开发者ID:glmcdona,项目名称:meddle,代码行数:9,

示例9: _compile

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):

if ext == '.rc':

# gcc requires '.rc' compiled to binary ('.res') files !!!

try:

self.spawn(["rc", "-r", src])

except DistutilsExecError, msg:

raise CompileError, msg

开发者ID:glmcdona,项目名称:meddle,代码行数:9,

示例10: UnixCCompiler__compile

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):

"""Compile a single source files with a Unix-style compiler."""

# HP ad-hoc fix, see ticket 1383

ccomp = self.compiler_so

if ccomp[0] == 'aCC':

# remove flags that will trigger ANSI-C mode for aCC

if '-Ae' in ccomp:

ccomp.remove('-Ae')

if '-Aa' in ccomp:

ccomp.remove('-Aa')

# add flags for (almost) sane C++ handling

ccomp += ['-AA']

self.compiler_so = ccomp

# ensure OPT environment variable is read

if 'OPT' in os.environ:

from distutils.sysconfig import get_config_vars

opt = " ".join(os.environ['OPT'].split())

gcv_opt = " ".join(get_config_vars('OPT')[0].split())

ccomp_s = " ".join(self.compiler_so)

if opt not in ccomp_s:

ccomp_s = ccomp_s.replace(gcv_opt, opt)

self.compiler_so = ccomp_s.split()

llink_s = " ".join(self.linker_so)

if opt not in llink_s:

self.linker_so = llink_s.split() + opt.split()

display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src)

try:

self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +

extra_postargs, display = display)

except DistutilsExecError:

msg = str(get_exception())

raise CompileError(msg)

开发者ID:ryfeus,项目名称:lambda-packs,代码行数:35,

示例11: build_extension

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [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,

示例12: _compile_helper

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def _compile_helper(self, content):

conftest = open("conftest.c", "w")

try:

with conftest:

conftest.write(content)

try:

self.compiler.compile(["conftest.c"], output_dir='')

except CompileError:

return False

return True

finally:

self._remove_conftest()

开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,

示例13: has_flag

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def has_flag(compiler, flagname):

"""Return a boolean indicating whether a flag name is supported on

the specified compiler.

"""

import tempfile

with tempfile.NamedTemporaryFile("w", suffix=".cpp") as f:

f.write("int main (int argc, char **argv) { return 0; }")

try:

compiler.compile([f.name], extra_postargs=[flagname])

except setuptools.distutils.errors.CompileError:

return False

return True

开发者ID:davidcaron,项目名称:pclpy,代码行数:15,

示例14: get_tf_abi

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def get_tf_abi(build_ext, include_dirs, lib_dirs, libs, cpp_flags):

last_err = None

cxx11_abi_macro = '_GLIBCXX_USE_CXX11_ABI'

for cxx11_abi in ['0', '1']:

try:

lib_file = test_compile(build_ext, 'test_tensorflow_abi',

macros=[(cxx11_abi_macro, cxx11_abi)],

include_dirs=include_dirs, library_dirs=lib_dirs,

libraries=libs, extra_preargs=cpp_flags,

code=textwrap.dedent('''\

#include

#include "tensorflow/core/framework/op.h"

#include "tensorflow/core/framework/op_kernel.h"

#include "tensorflow/core/framework/shape_inference.h"

void test() {

auto ignore = tensorflow::strings::StrCat("a", "b");

}

'''))

from tensorflow.python.framework import load_library

load_library.load_op_library(lib_file)

return cxx11_abi_macro, cxx11_abi

except (CompileError, LinkError):

last_err = 'Unable to determine CXX11 ABI to use with TensorFlow (see error above).'

except Exception:

last_err = 'Unable to determine CXX11 ABI to use with TensorFlow. ' \

'Last error:\n\n%s' % traceback.format_exc()

raise DistutilsPlatformError(last_err)

开发者ID:mlperf,项目名称:training_results_v0.6,代码行数:32,

示例15: get_cuda_dirs

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def get_cuda_dirs(build_ext, cpp_flags):

cuda_include_dirs = []

cuda_lib_dirs = []

cuda_home = os.environ.get('HOROVOD_CUDA_HOME')

if cuda_home:

cuda_include_dirs += ['%s/include' % cuda_home]

cuda_lib_dirs += ['%s/lib' % cuda_home, '%s/lib64' % cuda_home]

cuda_include = os.environ.get('HOROVOD_CUDA_INCLUDE')

if cuda_include:

cuda_include_dirs += [cuda_include]

cuda_lib = os.environ.get('HOROVOD_CUDA_LIB')

if cuda_lib:

cuda_lib_dirs += [cuda_lib]

if not cuda_include_dirs and not cuda_lib_dirs:

# default to /usr/local/cuda

cuda_include_dirs += ['/usr/local/cuda/include']

cuda_lib_dirs += ['/usr/local/cuda/lib', '/usr/local/cuda/lib64']

try:

test_compile(build_ext, 'test_cuda', libraries=['cudart'], include_dirs=cuda_include_dirs,

library_dirs=cuda_lib_dirs, extra_preargs=cpp_flags, code=textwrap.dedent('''\

#include

void test() {

cudaSetDevice(0);

}

'''))

except (CompileError, LinkError):

raise DistutilsPlatformError(

'CUDA library was not found (see error above).\n'

'Please specify correct CUDA location with the HOROVOD_CUDA_HOME '

'environment variable or combination of HOROVOD_CUDA_INCLUDE and '

'HOROVOD_CUDA_LIB environment variables.\n\n'

'HOROVOD_CUDA_HOME - path where CUDA include and lib directories can be found\n'

'HOROVOD_CUDA_INCLUDE - path to CUDA include directory\n'

'HOROVOD_CUDA_LIB - path to CUDA lib directory')

return cuda_include_dirs, cuda_lib_dirs

开发者ID:mlperf,项目名称:training_results_v0.6,代码行数:43,

示例16: _compile_cu

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def _compile_cu(self, sources, output_dir=None, macros=None,

include_dirs=None, debug=0, extra_preargs=None,

extra_postargs=None, depends=None):

# Compile CUDA C files, mainly derived from UnixCCompiler._compile().

macros, objects, extra_postargs, pp_opts, _build = \

self._setup_compile(output_dir, macros, include_dirs, sources,

depends, extra_postargs)

compiler_so = build.get_nvcc_path()

cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)

cuda_version = build.get_cuda_version()

postargs = _nvcc_gencode_options(cuda_version) + ['-O2']

postargs += ['-Xcompiler', '/MD']

print('NVCC options:', postargs)

for obj in objects:

try:

src, ext = _build[obj]

except KeyError:

continue

try:

self.spawn(compiler_so + cc_args + [src, '-o', obj] + postargs)

except errors.DistutilsExecError as e:

raise errors.CompileError(str(e))

return objects

开发者ID:cupy,项目名称:cupy,代码行数:29,

示例17: get_cpp_flags

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def get_cpp_flags(build_ext):

last_err = None

default_flags = ['-std=c++11', '-fPIC', '-O2', '-Wall']

# avx_flags = ['-mf16c', '-mavx'] if check_avx_supported() else []

avx_flags = []

flags_to_try = [

default_flags,

default_flags + ['-stdlib=libc++']

]

if avx_flags:

flags_to_try.append(default_flags + avx_flags)

flags_to_try.append(default_flags + ['-stdlib=libc++'] + avx_flags)

for cpp_flags in flags_to_try:

try:

test_compile(

build_ext, 'test_cpp_flags',

extra_compile_preargs=cpp_flags,

code=textwrap.dedent(

'''\

#include

void test() {

}

'''

)

)

return cpp_flags

except (CompileError, LinkError):

last_err = 'Unable to determine C++ compilation flags (see error above).'

except Exception:

last_err = 'Unable to determine C++ compilation flags. ' \

'Last error:\n\n%s' % traceback.format_exc()

raise DistutilsPlatformError(last_err)

开发者ID:NVIDIA,项目名称:nvtx-plugins,代码行数:43,

示例18: get_link_flags

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def get_link_flags(build_ext):

last_err = None

libtool_flags = ['-Wl,-exported_symbols_list']

ld_flags = []

flags_to_try = [ld_flags, libtool_flags]

for link_flags in flags_to_try:

try:

test_compile(build_ext, 'test_link_flags',

extra_link_preargs=link_flags,

code=textwrap.dedent('''\

void test() {

}

'''))

return link_flags

except (CompileError, LinkError):

last_err = 'Unable to determine C++ link flags (see error above).'

except Exception:

last_err = 'Unable to determine C++ link flags. ' \

'Last error:\n\n%s' % traceback.format_exc()

raise DistutilsPlatformError(last_err)

开发者ID:NVIDIA,项目名称:nvtx-plugins,代码行数:30,

示例19: get_tf_libs

​点赞 5

# 需要导入模块: from distutils import errors [as 别名]

# 或者: from distutils.errors import CompileError [as 别名]

def get_tf_libs(build_ext, lib_dirs, cpp_flags):

for tf_libs in [['tensorflow_framework'], []]:

try:

lib_file = test_compile(

build_ext,

'test_tensorflow_libs',

library_dirs=lib_dirs,

libraries=tf_libs,

extra_compile_preargs=cpp_flags,

code=textwrap.dedent('''\

void test() {

}

'''))

from tensorflow.python.framework import load_library

load_library.load_op_library(lib_file)

return tf_libs

except (CompileError, LinkError):

last_err = 'Unable to determine -l link flags to use with TensorFlow (see error above).'

except Exception:

last_err = 'Unable to determine -l link flags to use with TensorFlow. Last error:\n\n%s' % \

traceback.format_exc()

raise DistutilsPlatformError(last_err)

开发者ID:NVIDIA,项目名称:nvtx-plugins,代码行数:29,

注:本文中的distutils.errors.CompileError方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值