Equivalent to running:: f2py where `` =string.join( ,' ')``, but in Python. Unless ``-h`` is used, this function returns a dictionary containing information on generated modules and their dependencies on source files. You cannot build extension m
(comline_list)
| 424 | |
| 425 | |
| 426 | def run_main(comline_list): |
| 427 | """ |
| 428 | Equivalent to running:: |
| 429 | |
| 430 | f2py <args> |
| 431 | |
| 432 | where ``<args>=string.join(<list>,' ')``, but in Python. Unless |
| 433 | ``-h`` is used, this function returns a dictionary containing |
| 434 | information on generated modules and their dependencies on source |
| 435 | files. |
| 436 | |
| 437 | You cannot build extension modules with this function, that is, |
| 438 | using ``-c`` is not allowed. Use the ``compile`` command instead. |
| 439 | |
| 440 | Examples |
| 441 | -------- |
| 442 | The command ``f2py -m scalar scalar.f`` can be executed from Python as |
| 443 | follows. |
| 444 | |
| 445 | .. literalinclude:: ../../source/f2py/code/results/run_main_session.dat |
| 446 | :language: python |
| 447 | |
| 448 | """ |
| 449 | crackfortran.reset_global_f2py_vars() |
| 450 | f2pydir = os.path.dirname(os.path.abspath(cfuncs.__file__)) |
| 451 | fobjhsrc = os.path.join(f2pydir, 'src', 'fortranobject.h') |
| 452 | fobjcsrc = os.path.join(f2pydir, 'src', 'fortranobject.c') |
| 453 | # gh-22819 -- begin |
| 454 | parser = make_f2py_compile_parser() |
| 455 | args, comline_list = parser.parse_known_args(comline_list) |
| 456 | pyf_files, _ = filter_files("", "[.]pyf([.]src|)", comline_list) |
| 457 | # Checks that no existing modulename is defined in a pyf file |
| 458 | # TODO: Remove all this when scaninputline is replaced |
| 459 | if args.module_name: |
| 460 | if "-h" in comline_list: |
| 461 | modname = ( |
| 462 | args.module_name |
| 463 | ) # Directly use from args when -h is present |
| 464 | else: |
| 465 | modname = validate_modulename( |
| 466 | pyf_files, args.module_name |
| 467 | ) # Validate modname when -h is not present |
| 468 | comline_list += ['-m', modname] # needed for the rest of scaninputline |
| 469 | # gh-22819 -- end |
| 470 | files, options = scaninputline(comline_list) |
| 471 | auxfuncs.options = options |
| 472 | capi_maps.load_f2cmap_file(options['f2cmap_file']) |
| 473 | postlist = callcrackfortran(files, options) |
| 474 | isusedby = {} |
| 475 | for plist in postlist: |
| 476 | if 'use' in plist: |
| 477 | for u in plist['use'].keys(): |
| 478 | if u not in isusedby: |
| 479 | isusedby[u] = [] |
| 480 | isusedby[u].append(plist['name']) |
| 481 | for plist in postlist: |
| 482 | module_name = plist['name'] |
| 483 | if plist['block'] == 'python module' and '__user__' in module_name: |
no test coverage detected
searching dependent graphs…