[f2py] wrapping large Fortran code with f2py
pearu.peterson at gmail.com
Tue Feb 12 12:20:23 EET 2008
On Feb 12, 2008 7:49 AM, Vitaly Marin <vmarin3 at gatech.edu> wrote:
> I am trying to generate a python interface to a large code, written in a
> mix of Fortran and C, that has source in several sub-directories. I am
> interested to wrap most of the top-level subroutines but
> need everything else compiled. Since there are a all lot of Fortran
> files it is not possible to pass all the information
> to compile this code with f2py via the command line.
> I have stumbled on a very similar posting at
Btw, the statement in this message that it is not possible to build
extension module sources, is not true. One just should not use -c flag.
However, using setup.py in a Makefile is the recommended way.
> My question is how to complete step 4. My code contains multiple large
> Makefiles to compile Fortran/C code (for each static library). I have
> several static libraries.
> How can I let f2py to generate the .so file or files?
that explains how to use numpy.distutils for various tasks.
Examples of setup.py files can be found in (see in f2py_ext directory,
See also setup.py files in scipy subpackages. For example,
shows how to build .a library from Fortran sources and how to link
it with an extension module.
If the Makefiles are too complex to convert the library building steps to
setup.py, then you can still use libraries built by Makefile in the setup.py
script: just specify the library names in `libraries` argument (if needed, also
the paths to libraries in `library_dirs` argument) and make sure that libraries
are built before executing setup.py command.
If you run into troubles in creating setup.py script from the above information,
just let us know and I can give more detailed help.
More information about the f2py-users