forked from csc-training/hpc-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_libevolve.py
More file actions
21 lines (18 loc) · 790 Bytes
/
build_libevolve.py
File metadata and controls
21 lines (18 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from cffi import FFI
ffibuilder = FFI()
ffibuilder.cdef("""
void evolve(double *u, double *u_previous, int nx, int ny, double a, double dt, double dx2, double dy2)
""")
# set_source() gives the name of the python extension module to
# produce, and some C source code as a string. This C code needs
# to make the declarated functions, types and globals available,
# so it is often just the "#include".
ffibuilder.set_source("_libevolve",
"""
#include <string.h> // the C header of the library
""",
library_dirs = [], # here we can provide where the library is located,
# as we are using C standard library empty list is enough
libraries = ['libevolve'] # name of the library we want to interface
)
ffibuilder.compile(verbose=True)