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

Function main

numpy/linalg/lapack_lite/make_lite.py:334–388  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

332 f.write(f"#define {name} numpy_lapack_lite_{name}\n")
333
334def main():
335 if len(sys.argv) != 3:
336 print(__doc__)
337 return
338 # Make sure that patch and f2c are found on path
339 ensure_executable('f2c')
340 ensure_executable('patch')
341
342 wrapped_routines_file = sys.argv[1]
343 lapack_src_dir = sys.argv[2]
344 output_dir = os.path.join(os.path.dirname(__file__), 'build')
345
346 shutil.rmtree(output_dir, ignore_errors=True)
347 os.makedirs(output_dir)
348
349 wrapped_routines, ignores = getWrappedRoutineNames(wrapped_routines_file)
350 library = getLapackRoutines(wrapped_routines, ignores, lapack_src_dir)
351
352 dumpRoutineNames(library, output_dir)
353
354 for typename in types:
355 fortran_file = os.path.join(output_dir, f'f2c_{typename}.f')
356 c_file = fortran_file[:-2] + '.c'
357 print(f'creating {c_file} ...')
358 routines = library.allRoutinesByType(typename)
359 concatenateRoutines(routines, fortran_file)
360
361 # apply the patchpatch
362 patch_file = os.path.basename(fortran_file) + '.patch'
363 if os.path.exists(patch_file):
364 subprocess.check_call(['patch', '-u', fortran_file, patch_file])
365 print(f"Patched {fortran_file}")
366 try:
367 runF2C(fortran_file, output_dir)
368 except F2CError:
369 print(f'f2c failed on {fortran_file}')
370 break
371 scrubF2CSource(c_file)
372
373 # patch any changes needed to the C file
374 c_patch_file = os.path.basename(c_file) + '.patch'
375 if os.path.exists(c_patch_file):
376 subprocess.check_call(['patch', '-u', c_file, c_patch_file])
377
378 print()
379
380 create_name_header(output_dir)
381
382 for fname in os.listdir(output_dir):
383 if fname.endswith('.c') or fname == 'lapack_lite_names.h':
384 print('Copying ' + fname)
385 shutil.copy(
386 os.path.join(output_dir, fname),
387 os.path.abspath(os.path.dirname(__file__)),
388 )
389
390
391if __name__ == '__main__':

Callers 1

make_lite.pyFile · 0.70

Calls 15

ensure_executableFunction · 0.85
getWrappedRoutineNamesFunction · 0.85
getLapackRoutinesFunction · 0.85
dumpRoutineNamesFunction · 0.85
concatenateRoutinesFunction · 0.85
runF2CFunction · 0.85
scrubF2CSourceFunction · 0.85
create_name_headerFunction · 0.85
joinMethod · 0.80
allRoutinesByTypeMethod · 0.80
listdirMethod · 0.80
endswithMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…