本文整理汇总了Python中setuptools.command.build_ext.build_ext.build_extension方法的典型用法代码示例。如果您正苦于以下问题:Python build_ext.build_extension方法的具体用法?Python build_ext.build_extension怎么用?Python build_ext.build_extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools.command.build_ext.build_ext
的用法示例。
在下文中一共展示了build_ext.build_extension方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct_build_ext
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [as 别名]
def construct_build_ext(build_ext):
class WrappedBuildExt(build_ext):
def run(self):
try:
build_ext.run(self)
except BaseException as e:
raise CompilingFailed(e)
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except BaseException as e:
raise CompilingFailed(e)
return WrappedBuildExt
# ============================================================
# SETUP
# ============================================================
示例2: build_tf_extension
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [as 别名]
def build_tf_extension(build_ext, options):
check_tf_version()
tf_compile_flags, tf_link_flags = get_tf_flags(
build_ext, options['COMPILE_FLAGS'])
tensorflow_mpi_lib.define_macros = options['MACROS']
tensorflow_mpi_lib.include_dirs = options['INCLUDES']
tensorflow_mpi_lib.sources = options['SOURCES'] + \
['horovod/tensorflow/mpi_ops.cc']
tensorflow_mpi_lib.extra_compile_args = options['COMPILE_FLAGS'] + \
tf_compile_flags
tensorflow_mpi_lib.extra_link_args = options['LINK_FLAGS'] + tf_link_flags
tensorflow_mpi_lib.library_dirs = options['LIBRARY_DIRS']
tensorflow_mpi_lib.libraries = options['LIBRARIES']
build_ext.build_extension(tensorflow_mpi_lib)
# Return ABI flags used for TensorFlow compilation. We will use this flag
# to compile all the libraries.
return [flag for flag in tf_compile_flags if '_GLIBCXX_USE_CXX11_ABI' in flag]
示例3: build_extension
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [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).
示例4: build_common_extension
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [as 别名]
def build_common_extension(build_ext, options, abi_compile_flags):
common_mpi_lib.define_macros = options['MACROS']
common_mpi_lib.include_dirs = options['INCLUDES']
common_mpi_lib.sources = options['SOURCES'] + ['horovod/common/common.cc',
'horovod/common/mpi_message.cc',
'horovod/common/operations.cc',
'horovod/common/timeline.cc']
common_mpi_lib.extra_compile_args = options['COMPILE_FLAGS'] + \
abi_compile_flags
common_mpi_lib.extra_link_args = options['LINK_FLAGS']
common_mpi_lib.library_dirs = options['LIBRARY_DIRS']
common_mpi_lib.libraries = options['LIBRARIES']
build_ext.build_extension(common_mpi_lib)
示例5: build_extension
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [as 别名]
def build_extension(self, ext):
cc = self.compiler
if cc.compiler_type == "unix":
ext.extra_compile_args.append("--std=c++11")
if self.plat_name.startswith("macosx"):
ext.extra_compile_args.append("-mmacosx-version-min=10.9")
ext.extra_link_args.append("-mmacosx-version-min=10.9")
build_ext.build_extension(self, ext)
示例6: build_extension
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [as 别名]
def build_extension(self, ext):
name = ext.name
try:
build_ext.build_extension(self, ext)
except Exception:
e = sys.exc_info()[1]
sys.stdout.write('%s\n' % str(e))
warnings.warn(self.warning_message % ("The %s extension "
"module" % (name,),
"The output above "
"this warning shows how "
"the compilation "
"failed."))
示例7: build_extension
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [as 别名]
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except ext_errors as e:
print(e)
raise BuildFailed()
示例8: build_extension
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [as 别名]
def build_extension(self, ext):
name = ext.name
try:
build_ext.build_extension(self, ext)
except Exception:
e = sys.exc_info()[1]
sys.stdout.write('%s\n' % str(e))
warnings.warn(
self.warning_message +
'The %s extension module' % (name,) +
'The output above this warning shows how the compilation failed.')
示例9: build_torch_extension
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extension [as 别名]
def build_torch_extension(build_ext, options, abi_compile_flags):
check_torch_import()
have_cuda = is_torch_cuda()
if not have_cuda and check_macro(options['MACROS'], 'HAVE_CUDA'):
raise DistutilsPlatformError(
'Horovod build with GPU support was requested, but this PyTorch '
'installation does not support CUDA.')
# Update HAVE_CUDA to mean that PyTorch supports CUDA. Internally, we will be checking
# HOROVOD_GPU_(ALLREDUCE|ALLGATHER|BROADCAST) to decide whether we should use GPU
# version or transfer tensors to CPU memory for those operations.
updated_macros = set_macro(
options['MACROS'], 'HAVE_CUDA', str(int(have_cuda)))
# Create_extension overwrites these files which are customized, we need to protect them.
with protect_files('horovod/torch/mpi_lib/__init__.py',
'horovod/torch/mpi_lib_impl/__init__.py'):
from torch.utils.ffi import create_extension
ffi_iface = create_extension(
name='horovod.torch.mpi_lib',
headers=['horovod/torch/interface.h'] +
(['horovod/torch/interface_cuda.h'] if have_cuda else []),
with_cuda=have_cuda,
language='c',
package=True,
sources=[],
extra_compile_args=['-std=c11', '-fPIC', '-O2']
)
ffi_impl = create_extension(
name='horovod.torch.mpi_lib_impl',
headers=[],
with_cuda=have_cuda,
language='c++',
package=True,
source_extension='.cc',
define_macros=updated_macros,
include_dirs=options['INCLUDES'],
sources=options['SOURCES'] + ['horovod/torch/mpi_ops.cc',
'horovod/torch/handle_manager.cc',
'horovod/torch/ready_event.cc',
'horovod/torch/tensor_util.cc',
'horovod/torch/cuda_util.cc',
'horovod/torch/adapter.cc'],
extra_compile_args=options['COMPILE_FLAGS'] + abi_compile_flags,
extra_link_args=options['LINK_FLAGS'],
library_dirs=options['LIBRARY_DIRS'],
libraries=options['LIBRARIES']
)
for ffi, setuptools_ext in [(ffi_iface, torch_mpi_lib),
(ffi_impl, torch_mpi_lib_impl)]:
ffi_ext = ffi.distutils_extension()
# ffi_ext is distutils Extension, not setuptools Extension
for k, v in ffi_ext.__dict__.items():
setuptools_ext.__dict__[k] = v
build_ext.build_extension(setuptools_ext)
# run the customize_compiler