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