How to create a python extension module from a shared library?

Etienne Robillard tkadm30 at yandex.com
Wed Jan 3 06:12:25 EST 2018


Hi James,

I would love to write in C but I much prefer coding in Python :)

I was thinking that I could use Cython to dlopen the shared library 
dynamically with ctypes. No need to compile anything.


Best regards,

Etienne


Le 2018-01-03 à 05:30, James Chapman a écrit :
> In my opinion, just write your extension in C following the 
> traditional extension development guidelines unless you plan to 
> actively maintain and contribute your changes in the relevant projects 
> (CFFI and uWSGI).
>
> Assuming you get this to work, you're going to have to support it and 
> bug fix it. Something that initially will not be too difficult because 
> it will all be fresh in your head, but 6 months down the line when you 
> want to change something or discover a bug it's going to be very 
> difficult. Will you be able to attach a debugger and step through the 
> code?
>
> I've been down the route of trying to do something clever and even 
> succeeded. I then later regretted it, because what seemed like a good 
> idea at the time turned out to be a PITA to support. Go with what's 
> supported, go with what's documented, don't modify core components if 
> you don't absolutely have to, because you'll have to modify those 
> components with each update and ultimately you just end up generating 
> work for yourself.
>
>
> James
>
>
>
> On 2 January 2018 at 21:21, Etienne Robillard <tkadm30 at yandex.com 
> <mailto:tkadm30 at yandex.com>> wrote:
>
>     Hi James,
>
>     Part of the problem is because the CFFI and uWSGI developers
>     aren't interested to support this. I need to modify CFFI to
>     support preprocessing C headers with clang.cindex myself.
>
>     I also need to make sure its possible to attach my Python script
>     to the master uWSGI process to dispatch FIFO commands.
>
>     Clang is needed because CFFI doesn't support preprocessing C
>     headers with #define or #include directives.
>
>     Best regards,
>
>     Etienne
>
>
>

-- 
Etienne Robillard
tkadm30 at yandex.com
https://www.isotopesoftware.ca/




More information about the Python-list mailing list