How to create a python extension module from a shared library?
Etienne Robillard
tkadm30 at yandex.com
Tue Jan 2 06:44:51 EST 2018
Here's my ffi_build.py script:
https://bitbucket.org/tkadm30/libuwsgictl/src/956f6ca24f9111c1d8b3ce90cf17173a6e5ae3e2/ffi_build.py?at=default&fileviewer=file-view-default
Not really sure how to preprocess the uwsgi.h header with clang.cindex
in cffi.
I can load the shared lib with :
>>> lib = clang.cindex.cdll.LoadLibrary(c_lib)
Any ideas how to compile lib into a python extension module with cffi?
Etienne
Le 2018-01-02 à 05:17, Etienne Robillard a écrit :
> Hi James,
>
> Thanks for your input.
>
> I want to make a native Python application (uwsgictl) to dispatch FIFO
> commands to the master uWSGI process.
>
> uwsgictl would depend on libuwsgi.so, a uWSGI plugin included in the
> distribution.
>
> My goal is to use CFFI to generate python bindings for libuwsgi.so
> using clang interpreter. :)
>
>
> Best regards,
>
> Etienne
>
>
> Le 2018-01-02 à 05:06, James Chapman a écrit :
>> Hi Etienne,
>>
>> I'm not familiar with uSWGI, so I started here:
>> https://uwsgi-docs.readthedocs.io/en/latest/Hooks.html
>> AFAIK there are a number of hooks already exposed and available to
>> Python apps.
>>
>> However, if I've understood your question correctly, you want to
>> extend uWSGI itself by writing some python code which is then
>> translated/generated into C code? You refer to AST generation but why
>> are you doing this? Maybe my unfamiliarity with uWSGI is preventing
>> me from understanding exactly what it is you are trying to do, but
>> further clarification would go a long way.
>>
>> If your goal is actually to extend uWSGI via a plugin, then there's
>> more to just writing some python, you'll need to write some C code (I
>> wouldn't bother trying to generate this as it'll probably not work):
>> https://github.com/unbit/uwsgi-docs/blob/master/tutorials/WritingPlugins.rst
>>
>>
>> If you look here, there's a link to each 3rd party plugin (mostly
>> GitHub) where you can see the source code for each plugin. This is a
>> very good starting point as there are many examples here:
>> https://uwsgi-docs.readthedocs.io/en/latest/ThirdPartyPlugins.html
>>
>> Perhaps you can clarify.
>>
>> James
>>
>>
>>
>>
>> On 30 December 2017 at 01:00, Etienne Robillard <tkadm30 at yandex.com
>> <mailto:tkadm30 at yandex.com>> wrote:
>>
>> Hi all,
>>
>> I would like to extend uWSGI by creating a CPython extension
>> module for the libuwsgi.so shared library included in the
>> distribution.
>>
>> My goal is to use this automatically generated CPython module for
>> extending uWSGI.
>>
>>
>
--
Etienne Robillard
tkadm30 at yandex.com
https://www.isotopesoftware.ca/
More information about the Python-list
mailing list