本文整理匯總了Python中distutils.unixccompiler.UnixCCompiler方法的典型用法代碼示例。如果您正苦於以下問題:Python unixccompiler.UnixCCompiler方法的具體用法?Python unixccompiler.UnixCCompiler怎麽用?Python unixccompiler.UnixCCompiler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類distutils.unixccompiler
的用法示例。
在下文中一共展示了unixccompiler.UnixCCompiler方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _compile
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
# For sources other than CUDA C ones, just call the super class method.
if os.path.splitext(src)[1] != '.cu':
return unixccompiler.UnixCCompiler._compile(
self, obj, src, ext, cc_args, extra_postargs, pp_opts)
# For CUDA C source files, compile them with NVCC.
_compiler_so = self.compiler_so
try:
nvcc_path = CUDA['nvcc']
post_args = CUDA['post_args']
# TODO? base_opts = build.get_compiler_base_options()
self.set_executable('compiler_so', nvcc_path)
return unixccompiler.UnixCCompiler._compile(
self, obj, src, ext, cc_args, post_args, pp_opts)
finally:
self.compiler_so = _compiler_so
示例2: _compile_cu
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [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
示例3: get_ethtool_macro
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [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 <linux/ethtool.h>")
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)
示例4: _comiple_unix_hipcc
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def _comiple_unix_hipcc(self,
obj, src, ext, cc_args, extra_postargs, pp_opts):
# For CUDA C source files, compile them with HIPCC.
_compiler_so = self.compiler_so
try:
rcom_path = build.get_hipcc_path()
base_opts = build.get_compiler_base_options()
self.set_executable('compiler_so', rcom_path)
postargs = ['-O2', '-fPIC']
print('HIPCC options:', postargs)
return unixccompiler.UnixCCompiler._compile(
self, obj, src, ext, base_opts + cc_args, postargs, pp_opts)
finally:
self.compiler_so = _compiler_so
示例5: link
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def link(self, target_desc, objects, output_filename, *args):
use_hipcc = False
if use_hip:
for i in objects:
if 'cupy_thrust.o' in i:
use_hipcc = True
if use_hipcc:
_compiler_cxx = self.compiler_cxx
try:
rcom_path = build.get_hipcc_path()
self.set_executable('compiler_cxx', rcom_path)
return unixccompiler.UnixCCompiler.link(
self, target_desc, objects, output_filename, *args)
finally:
self.compiler_cxx = _compiler_cxx
else:
return unixccompiler.UnixCCompiler.link(
self, target_desc, objects, output_filename, *args)
示例6: setUp
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def setUp(self):
self._backup_platform = sys.platform
self._backup_get_config_var = sysconfig.get_config_var
class CompilerWrapper(UnixCCompiler):
def rpath_foo(self):
return self.runtime_library_dir_option('/foo')
self.cc = CompilerWrapper()
示例7: _compile
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
# For sources other than CUDA C ones, just call the super class method.
if os.path.splitext(src)[1] != '.cu':
return unixccompiler.UnixCCompiler._compile(
self, obj, src, ext, cc_args, extra_postargs, pp_opts)
if use_hip:
return self._comiple_unix_hipcc(
obj, src, ext, cc_args, extra_postargs, pp_opts)
# For CUDA C source files, compile them with NVCC.
_compiler_so = self.compiler_so
try:
nvcc_path = build.get_nvcc_path()
base_opts = build.get_compiler_base_options()
self.set_executable('compiler_so', nvcc_path)
cuda_version = build.get_cuda_version()
postargs = _nvcc_gencode_options(cuda_version) + [
'-O2', '--compiler-options="-fPIC"', '--std=c++11']
print('NVCC options:', postargs)
return unixccompiler.UnixCCompiler._compile(
self, obj, src, ext, base_opts + cc_args, postargs, pp_opts)
finally:
self.compiler_so = _compiler_so
示例8: _compile_cu
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [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
示例9: setUp
# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def setUp(self):
self._backup_platform = sys.platform
self._backup_get_config_var = sysconfig.get_config_var
self._backup_get_config_vars = sysconfig.get_config_vars
class CompilerWrapper(UnixCCompiler):
def rpath_foo(self):
return self.runtime_library_dir_option('/foo')
self.cc = CompilerWrapper()