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