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

Function create_name_header

numpy/linalg/lapack_lite/make_lite.py:286–330  ·  view source on GitHub ↗
(output_dir)

Source from the content-addressed store, hash-verified

284 raise SystemExit(name + ' not found')
285
286def create_name_header(output_dir):
287 routine_re = re.compile(r'^ (subroutine|.* function)\s+(\w+)\(.*$',
288 re.I)
289 extern_re = re.compile(r'^extern [a-z]+ ([a-z0-9_]+)\(.*$')
290
291 # BLAS/LAPACK symbols
292 symbols = set(['xerbla'])
293 for fn in os.listdir(output_dir):
294 fn = os.path.join(output_dir, fn)
295
296 if not fn.endswith('.f'):
297 continue
298
299 with open(fn) as f:
300 for line in f:
301 m = routine_re.match(line)
302 if m:
303 symbols.add(m.group(2).lower())
304
305 # f2c symbols
306 f2c_symbols = set()
307 with open('f2c.h') as f:
308 for line in f:
309 m = extern_re.match(line)
310 if m:
311 f2c_symbols.add(m.group(1))
312
313 with open(os.path.join(output_dir, 'lapack_lite_names.h'), 'w') as f:
314 f.write(HEADER_BLURB)
315 f.write(
316 "/*\n"
317 " * This file renames all BLAS/LAPACK and f2c symbols to avoid\n"
318 " * dynamic symbol name conflicts, in cases where e.g.\n"
319 " * integer sizes do not match with 'standard' ABI.\n"
320 " */\n")
321
322 # Rename BLAS/LAPACK symbols
323 for name in sorted(symbols):
324 f.write("#define %s_ BLAS_FUNC(%s)\n" % (name, name))
325
326 # Rename also symbols that f2c exports itself
327 f.write("\n"
328 "/* Symbols exported by f2c.c */\n")
329 for name in sorted(f2c_symbols):
330 f.write("#define %s numpy_lapack_lite_%s\n" % (name, name))
331
332def main():
333 if len(sys.argv) != 3:

Callers 1

mainFunction · 0.85

Calls 8

openFunction · 0.85
listdirMethod · 0.80
endswithMethod · 0.80
lowerMethod · 0.80
compileMethod · 0.45
joinMethod · 0.45
addMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected