MCPcopy Index your code
hub / github.com/numpy/numpy / create_name_header

Function create_name_header

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

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls 8

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…