()
| 332 | f.write(f"#define {name} numpy_lapack_lite_{name}\n") |
| 333 | |
| 334 | def 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 | |
| 391 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…