Using via numpy.distutils#
Legacy
This submodule is considered legacy and will no longer receive updates. This could also mean it will be removed in future NumPy versions. distutils has been removed in favor of meson see
Status of numpy.distutils and migration advice.
numpy.distutils is part of NumPy, and extends the standard Python
distutils module to deal with Fortran sources and F2PY signature files, e.g.
compile Fortran sources, call F2PY to construct extension modules, etc.
Extensions to distutils#
numpy.distutils extends distutils with the following features:
- Extensionclass argument- sourcesmay contain Fortran source files. In addition, the list- sourcesmay contain at most one F2PY signature file, and in this case, the name of an Extension module must match with the- <modulename>used in signature file. It is assumed that an F2PY signature file contains exactly one- python moduleblock.- If - sourcesdo not contain a signature file, then F2PY is used to scan Fortran source files to construct wrappers to the Fortran codes.- Additional options to the F2PY executable can be given using the - Extensionclass argument- f2py_options.
- The following new - distutilscommands are defined:- build_src
- to construct Fortran wrapper extension modules, among many other things. 
- config_fc
- to change Fortran compiler options. 
 - Additionally, the - build_extand- build_clibcommands are also enhanced to support Fortran sources.- Run - 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, one can choose different Fortran compilers by using the - build_extcommand option- --fcompiler=<Vendor>. Here- <Vendor>can be one of the following names (on- linuxsystems):- absoft compaq fujitsu g95 gnu gnu95 intel intele intelem lahey nag nagfor nv pathf95 pg vast - See - numpy_distutils/fcompiler.pyfor an up-to-date list of supported compilers for different platforms, or run- python -m numpy.f2py -c --backend distutils --help-fcompiler