This is a minimal working example for using Fortran to write Python extension.
src\fortext\algo\math.f90
contains a Fortran subroutine factorial
.
We are to compile math.f90
into an extension fortext.algo.math
.
pip install .
Then, we can use math.factorial()
as:
from fortext.algo import math
print(math.factorial(5))
This example is built and tested with Python 3.8 to 3.11, on Ubuntu, Windows and MacOS.
OS | Status |
---|---|
Ubuntu | |
Windows | |
MacOS |