[Numpy-discussion] f2py - how to use .pyf files?

Fernando Perez fperez.net@gmail....
Fri Jul 18 17:39:55 CDT 2008


Howdy,

again f2py...  Since I can't seem to figure out how to pass the
--fcompiler option to f2py via setup.py/distutils, I decided to just
do things for now via a plain makefile.  But I'm struggling here too.
The problem is this: the call

f2py -c --fcompiler=gfortran -m text2 Text2.f90

works perfectly, and at some point in the output I see

customize Gnu95FCompiler
Found executable /usr/bin/gfortran

and the result is a nice text2.so module.  But I'd like to clean up a
bit the python interface to the fortran routines, so I did the usual

f2py -h text2.pyf Text2.f90

to create the .pyf, edited the pyf to adjust and 'pythonize' the
interface, and then when I try to build using this pyf, I get a crash
and the *same* gfortran option is now not recognized:

maqroll[felipe_fortran]> f2py -c --fcompiler=gfortran text2.pyf
Unknown vendor: "gfortran"
Traceback (most recent call last):
  File "/usr/bin/f2py", line 26, in <module>
    main()
  File "/home/fperez/usr/opt/lib/python2.5/site-packages/numpy/f2py/f2py2e.py",
line 560, in main
    run_compile()
  File "/home/fperez/usr/opt/lib/python2.5/site-packages/numpy/f2py/f2py2e.py",
line 536, in run_compile
    ext = Extension(**ext_args)
  File "/home/fperez/usr/opt/lib/python2.5/site-packages/numpy/distutils/extension.py",
line 45, in __init__
    export_symbols)
  File "/usr/lib/python2.5/distutils/extension.py", line 106, in __init__
    assert type(name) is StringType, "'name' must be a string"
AssertionError: 'name' must be a string


Note that it doesn't matter if I add Text2.f90 or not to the above
call, it still fails.

I could swear I'd done similar things in the past without any problems
(albeit with f77 sources), and the user guide

http://cens.ioc.ee/projects/f2py2e/usersguide/index.html#three-ways-to-wrap-getting-started

gives instructions very much along the lines of what I'm doing.  Are
these changes since the integration into numpy, regressions, or
mistakes on how I'm calling it?

Thanks for  any help,

f


More information about the Numpy-discussion mailing list