本文整理汇总了Python中numpy.distutils.customized_ccompiler方法的典型用法代码示例。如果您正苦于以下问题:Python distutils.customized_ccompiler方法的具体用法?Python distutils.customized_ccompiler怎么用?Python distutils.customized_ccompiler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.distutils
的用法示例。
在下文中一共展示了distutils.customized_ccompiler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: library_extensions
# 需要导入模块: from numpy import distutils [as 别名]
# 或者: from numpy.distutils import customized_ccompiler [as 别名]
def library_extensions(self):
c = customized_ccompiler()
static_exts = []
if c.compiler_type != 'msvc':
# MSVC doesn't understand binutils
static_exts.append('.a')
if sys.platform == 'win32':
static_exts.append('.lib') # .lib is used by MSVC and others
if self.search_static_first:
exts = static_exts + [so_ext]
else:
exts = [so_ext] + static_exts
if sys.platform == 'cygwin':
exts.append('.dll.a')
if sys.platform == 'darwin':
exts.append('.dylib')
return exts
示例2: have_compiler
# 需要导入模块: from numpy import distutils [as 别名]
# 或者: from numpy.distutils import customized_ccompiler [as 别名]
def have_compiler():
""" Return True if there appears to be an executable compiler
"""
compiler = customized_ccompiler()
try:
cmd = compiler.compiler # Unix compilers
except AttributeError:
try:
if not compiler.initialized:
compiler.initialize() # MSVC is different
except (DistutilsError, ValueError):
return False
cmd = [compiler.cc]
try:
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
p.stdout.close()
p.stderr.close()
p.wait()
except OSError:
return False
return True
示例3: calc_info
# 需要导入模块: from numpy import distutils [as 别名]
# 或者: from numpy.distutils import customized_ccompiler [as 别名]
def calc_info(self):
c = customized_ccompiler()
lib_dirs = self.get_lib_dirs()
openblas_libs = self.get_libs('libraries', self._lib_names)
if openblas_libs == self._lib_names: # backward compat with 1.8.0
openblas_libs = self.get_libs('openblas_libs', self._lib_names)
info = self.check_libs(lib_dirs, openblas_libs, [])
if c.compiler_type == "msvc" and info is None:
from numpy.distutils.fcompiler import new_fcompiler
f = new_fcompiler(c_compiler=c)
if f and f.compiler_type == 'gnu95':
# Try gfortran-compatible library files
info = self.check_msvc_gfortran_libs(lib_dirs, openblas_libs)
# Skip lapack check, we'd need build_ext to do it
assume_lapack = True
elif info:
assume_lapack = False
info['language'] = 'c'
if info is None:
return
# Add extra info for OpenBLAS
extra_info = self.calc_extra_info()
dict_append(info, **extra_info)
if not (assume_lapack or self.check_embedded_lapack(info)):
return
info['define_macros'] = [('HAVE_CBLAS', None)]
self.set_info(**info)
示例4: check_embedded_lapack
# 需要导入模块: from numpy import distutils [as 别名]
# 或者: from numpy.distutils import customized_ccompiler [as 别名]
def check_embedded_lapack(self, info):
res = False
c = customized_ccompiler()
tmpdir = tempfile.mkdtemp()
s = """void zungqr_();
int main(int argc, const char *argv[])
{
zungqr_();
return 0;
}"""
src = os.path.join(tmpdir, 'source.c')
out = os.path.join(tmpdir, 'a.out')
# Add the additional "extra" arguments
try:
extra_args = info['extra_link_args']
except Exception:
extra_args = []
if sys.version_info < (3, 5) and sys.version_info > (3, 0) and c.compiler_type == "msvc":
extra_args.append("/MANIFEST")
try:
with open(src, 'wt') as f:
f.write(s)
obj = c.compile([src], output_dir=tmpdir)
try:
c.link_executable(obj, out, libraries=info['libraries'],
library_dirs=info['library_dirs'],
extra_postargs=extra_args)
res = True
except distutils.ccompiler.LinkError:
res = False
finally:
shutil.rmtree(tmpdir)
return res
示例5: test_compile2
# 需要导入模块: from numpy import distutils [as 别名]
# 或者: from numpy.distutils import customized_ccompiler [as 别名]
def test_compile2(self):
# Compile source and link the second source
tsi = self.c_temp2
c = customized_ccompiler()
extra_link_args = tsi.calc_extra_info()['extra_link_args']
previousDir = os.getcwd()
try:
# Change directory to not screw up directories
os.chdir(self._dir2)
c.compile([os.path.basename(self._src2)], output_dir=self._dir2,
extra_postargs=extra_link_args)
# Ensure that the object exists
assert_(os.path.isfile(self._src2.replace('.c', '.o')))
finally:
os.chdir(previousDir)