Python:cffi
lastmod 2024-01-08created 2021-12-063 edits
Example
Installation:
Linking a C library:
from cffi import FFI
ffibuilder = FFI()
ffibuilder.cdef("""
double sqrt(double x);
""")
ffibuilder.set_source("_libmath",
"""
#include <math.h>
""",
library_dirs = [],
libraries = ['m']
)
ffibuilder.compile(verbose=True)
You must call ffibuilder.compile at the end to produce a shared library that Python can link.
Using the library: