MCPcopy Create free account
hub / github.com/numpy/numpy / check_symbols

Method check_symbols

numpy/distutils/system_info.py:2404–2445  ·  view source on GitHub ↗
(self, info)

Source from the content-addressed store, hash-verified

2402 return info
2403
2404 def check_symbols(self, info):
2405 res = False
2406 c = customized_ccompiler()
2407
2408 tmpdir = tempfile.mkdtemp()
2409
2410 prototypes = "\n".join("void %s%s%s();" % (self.symbol_prefix,
2411 symbol_name,
2412 self.symbol_suffix)
2413 for symbol_name in self._require_symbols)
2414 calls = "\n".join("%s%s%s();" % (self.symbol_prefix,
2415 symbol_name,
2416 self.symbol_suffix)
2417 for symbol_name in self._require_symbols)
2418 s = textwrap.dedent("""\
2419 %(prototypes)s
2420 int main(int argc, const char *argv[])
2421 {
2422 %(calls)s
2423 return 0;
2424 }""") % dict(prototypes=prototypes, calls=calls)
2425 src = os.path.join(tmpdir, 'source.c')
2426 out = os.path.join(tmpdir, 'a.out')
2427 # Add the additional "extra" arguments
2428 try:
2429 extra_args = info['extra_link_args']
2430 except Exception:
2431 extra_args = []
2432 try:
2433 with open(src, 'w') as f:
2434 f.write(s)
2435 obj = c.compile([src], output_dir=tmpdir)
2436 try:
2437 c.link_executable(obj, out, libraries=info['libraries'],
2438 library_dirs=info['library_dirs'],
2439 extra_postargs=extra_args)
2440 res = True
2441 except distutils.ccompiler.LinkError:
2442 res = False
2443 finally:
2444 shutil.rmtree(tmpdir)
2445 return res
2446
2447class openblas_lapack_info(openblas_info):
2448 section = 'openblas'

Callers 1

_calc_infoMethod · 0.95

Calls 5

openFunction · 0.85
customized_ccompilerFunction · 0.70
joinMethod · 0.45
writeMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected