本文整理匯總了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)