本文整理汇总了Python中setuptools.command.build_ext.build_ext.build_extensions方法的典型用法代码示例。如果您正苦于以下问题:Python build_ext.build_extensions方法的具体用法?Python build_ext.build_extensions怎么用?Python build_ext.build_extensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools.command.build_ext.build_ext
的用法示例。
在下文中一共展示了build_ext.build_extensions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
link_opts = self.l_opts.get(ct, [])
if ct == 'unix':
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
for ext in self.extensions:
ext.define_macros = [
('VERSION_INFO', '"{}"'.format(self.distribution.get_version()))
]
ext.extra_compile_args = opts
ext.extra_link_args = link_opts
build_ext.build_extensions(self)
示例2: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
comp = self.compiler.compiler_type
if comp in ('unix', 'cygwin', 'mingw32'):
# Check if build is with OpenMP
if use_omp:
extra_compile_args = ['-std=c99', '-O3', '-fopenmp']
extra_link_args=['-lgomp']
else:
extra_compile_args = ['-std=c99', '-O3']
extra_link_args = []
elif comp == 'msvc':
extra_compile_args = ['/Ox']
extra_link_args = []
if use_omp:
extra_compile_args.append('/openmp')
else:
# Add support for more compilers here
raise ValueError('Compiler flags undefined for %s. Please modify setup.py and add compiler flags'
% comp)
self.extensions[0].extra_compile_args = extra_compile_args
self.extensions[0].extra_link_args = extra_link_args
build_ext.build_extensions(self)
示例3: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
if not sys.platform == 'darwin':
opts.append('-fopenmp') # For pqk-means
opts.append('-march=native') # For fast SIMD computation of L2 distance
opts.append('-mtune=native') # Do optimization (It seems this doesn't boost, but just in case)
opts.append('-Ofast') # This makes the program faster
for ext in self.extensions:
ext.extra_compile_args = opts
if not sys.platform == 'darwin':
ext.extra_link_args = ['-fopenmp'] # Because of PQk-means
build_ext.build_extensions(self)
示例4: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == "unix":
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, "-fvisibility=hidden"):
opts.append("-fvisibility=hidden")
elif ct == "msvc":
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
if ext.language == "c++":
ext.extra_compile_args += opts
ext.extra_link_args += opts
build_ext.build_extensions(self)
### Build Tools End ###
示例5: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
compile_so_command = self.compiler.compiler_so
if "-Wstrict-prototypes" in compile_so_command:
compile_so_command.remove("-Wstrict-prototypes")
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
link_opts = self.l_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = link_opts
build_ext.build_extensions(self)
示例6: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
if not has_cython:
log.info(
"%s is not installed. Pre-generated *.c sources will be "
"will be used to build the extensions." % required_cython
)
try:
_build_ext.build_extensions(self)
except Exception as e:
if with_cython:
raise
from distutils.errors import DistutilsModuleError
# optional compilation failed: we delete 'ext_modules' and make sure
# the generated wheel is 'pure'
del self.distribution.ext_modules[:]
try:
bdist_wheel = self.get_finalized_command("bdist_wheel")
except DistutilsModuleError:
# 'bdist_wheel' command not available as wheel is not installed
pass
else:
bdist_wheel.root_is_pure = True
log.error('error: building extensions failed: %s' % e)
示例7: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == "unix":
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, "-fvisibility=hidden"):
opts.append("-fvisibility=hidden")
elif ct == "msvc":
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
build_ext.build_extensions(self)
示例8: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
self.compiler.src_extensions.append('.cu')
self.compiler.set_executable('compiler_so', 'nvcc')
self.compiler.set_executable('linker_so', 'nvcc --shared')
if hasattr(self.compiler, '_c_extensions'):
self.compiler._c_extensions.append('.cu') # needed for Windows
self.compiler.spawn = self.spawn
build_ext.build_extensions(self)
示例9: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
use_openmp = self._check_openmp_support()
if use_openmp:
for ext in self.extensions:
if not ext.extra_compile_args:
ext.extra_compile_args = []
ext.extra_compile_args.append('-fopenmp')
if not ext.extra_link_args:
ext.extra_link_args = []
ext.extra_link_args.append('-fopenmp')
# Add language level directive (for the cython compiler)
for ext in self.extensions:
ext.compiler_directives = {'language_level' : sys.version_info[0]}
# Chain to method in parent class.
build_ext.build_extensions(self)
if not _CYTHON_INSTALLED:
log.info('No supported version of Cython installed. '
'Installing from compiled files.')
for extension in self.extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in ('.pyx', '.py'):
if extension.language == 'c++':
ext = '.cpp'
else:
ext = '.c'
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
# Custom clean command to remove build artifacts
示例10: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
# Compile OSQP using CMake
# Create build directory
if os.path.exists(osqp_build_dir):
sh.rmtree(osqp_build_dir)
os.makedirs(osqp_build_dir)
os.chdir(osqp_build_dir)
try:
check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build OSQP")
# Compile static library with CMake
call(['cmake'] + cmake_args + ['..'])
call(['cmake', '--build', '.', '--target', 'osqpstatic'] +
cmake_build_flags)
# Change directory back to the python interface
os.chdir(current_dir)
# Copy static library to src folder
lib_origin = [osqp_build_dir, 'out'] + lib_subdir + [lib_name]
lib_origin = os.path.join(*lib_origin)
copyfile(lib_origin, os.path.join('extension', 'src', lib_name))
# Run extension
build_ext.build_extensions(self)
示例11: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
opts_remove = self.c_opts_remove.get(ct, [])
if ct == "unix":
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, "-fvisibility=hidden"):
opts.append("-fvisibility=hidden")
self.compiler.compiler = [
o for o in self.compiler.compiler if o not in opts_remove
]
self.compiler.compiler_cxx = [
o for o in self.compiler.compiler_cxx if o not in opts_remove
]
self.compiler.compiler_so = [
o for o in self.compiler.compiler_so if o not in opts_remove
]
elif ct == "msvc":
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
if opts_remove:
raise NotImplementedError
for ext in self.extensions:
ext.extra_compile_args = opts
build_ext.build_extensions(self)
示例12: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
build_ext.build_extensions(self)
示例13: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' %
self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = deepcopy(opts)
ext.extra_link_args = deepcopy(opts)
lang = ext.language or self.compiler.detect_language(ext.sources)
if lang == 'c++':
ext.extra_compile_args.append(cpp_flag(self.compiler))
ext.extra_link_args.append(cpp_flag(self.compiler))
build_ext.build_extensions(self)
示例14: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
link_opts = self.l_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = link_opts
# third-party libraries flags
localincl = "third-party"
if not os.path.exists(os.path.join(localincl, "eigen_3.3.7", "Eigen",
"Core")):
raise RuntimeError("couldn't find Eigen headers")
include_dirs = [
os.path.join(localincl, "eigen_3.3.7"),
]
for ext in self.extensions:
ext.include_dirs = include_dirs + ext.include_dirs
# run standard build procedure
build_ext.build_extensions(self)
示例15: build_extensions
# 需要导入模块: from setuptools.command.build_ext import build_ext [as 别名]
# 或者: from setuptools.command.build_ext.build_ext import build_extensions [as 别名]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if use_omp:
opts.append('-fopenmp')
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
build_ext.build_extensions(self)