numpy.distutils is part of NumPy extending standard Python
to deal with Fortran sources and F2PY signature files, e.g. compile Fortran
sources, call F2PY to construct extension modules, etc.
Consider the following setup file:
from __future__ import division, absolute_import, print_function from numpy.distutils.core import Extension ext1 = Extension(name = 'scalar', sources = ['scalar.f']) ext2 = Extension(name = 'fib2', sources = ['fib2.pyf', 'fib1.f']) if __name__ == "__main__": from numpy.distutils.core import setup setup(name = 'f2py_example', description = "F2PY Users Guide examples", author = "Pearu Peterson", author_email = "email@example.com", ext_modules = [ext1, ext2] ) # End of setup_example.py
python setup_example.py build
will build two extension modules
fib2 to the
distutils with the following features:
sourcesmay contain Fortran source files. In addition, the list
sourcesmay contain at most one F2PY signature file, and then the name of an Extension module must match with the
used in signature file. It is assumed that an F2PY signature file contains exactly onepython module`` block.
sourcesdoes not contain a signature files, then F2PY is used to scan Fortran source files for routine signatures to construct the wrappers to Fortran codes.
Additional options to F2PY process can be given using
The following new
distutilscommands are defined:
to construct Fortran wrapper extension modules, among many other things.
to change Fortran compiler options
as well as
build_clibcommands are enhanced to support Fortran sources.
python <setup.py file> config_fc build_src build_ext --help
to see available options for these commands.
When building Python packages containing Fortran sources, then one can choose different Fortran compilers by using
--fcompiler=. Here `` can be one of the following names:
absoft sun mips intel intelv intele intelev nag compaq compaqv gnu vast pg hpux
numpy_distutils/fcompiler.pyfor up-to-date list of supported compilers or run
f2py -c --help-fcompiler