Importing Fortran libraries from Python
is easy and highly effective.
We write modern Fortran code from scratch explicitly for the purpose of importing into Python.
Here is an example
.appveyor.yml script useful for CI with f2py.
pyproject.toml below is also required.
image: - Visual Studio 2017 - Ubuntu stack: python 3 environment: PY_DIR: C:\Python36-x64 MINGW_DIR: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin clone_depth: 3 build: off init: - cmd: set PATH=%PY_DIR%;%PY_DIR%\Scripts;%PATH% - cmd: set PATH=%MINGW_DIR%;%PATH% install: - pip install -e .[tests] - cmd: del *.pyd - cmd: python setup.py build_ext --inplace --compiler=mingw32 test_script: pytest -rsv
Why do we first pip install?
To ensure Numpy is installed before building with
[build-system] requires = ["setuptools", "wheel", "numpy"]
For Windows only, this will in general create corrupted
.pyd on Windows, so as in
.appveyor.yml above, we delete these
.pyd files and generate with MinGW compiler.
This two-step process can be avoided (on Windows) by creating file