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] test_script: pytest -rsv
Why do we first pip install?
To ensure Numpy is installed before building with
[build-system] requires = ["setuptools", "wheel", "numpy"]
setup.py must include:
from pathlib import Path import os if os.name == 'nt': sfn = Path(__file__).parent / 'setup.cfg' stxt = sfn.read_text() if '[build_ext]' not in stxt: with sfn.open('a') as f: f.write("[build_ext]\ncompiler = mingw32")
this says that if the system is Windows, specify MinGW compiler without requiring root.