Reputation: 329
OS: CentOS 6 (64bit)
I have a dynamic library (.so) in C. And I want to create an abstraction layer of Python over it and then use it to implement my logic. I have decided to use CFFI for this since it doesn't deal with any kind of dsl (domain specific language).
Couple of things I wanted to know:
Thanks
Upvotes: 3
Views: 2213
Reputation: 154494
Two good starting points:
The CFFI documentation, and specifically the ABI out of line example: https://cffi.readthedocs.org/en/latest/overview.html#out-of-line-example-abi-level-out-of-line
My CFFI example repository: https://github.com/wolever/python-cffi-example
Between the two you shouldn't have too much trouble putting together your wrapper.
And to your second question: if the shared library you're wrapping is very simple (ex, a few function calls, simle data structures) you might find ctypes
simpler (as it's part of the standard library).
Upvotes: 4