[Geany-devel] Python Plugins, re-hashed

Lex Trotman elextr at xxxxx
Sat Dec 4 05:21:14 UTC 2010

On 4 December 2010 13:12, Matthew Brush <matthewbrush at gmail.com> wrote:
> Hi,
> I started working on Python plugin support for Geany. Some of the code and
> the general approach is based on what Māris Fogels had started at
> https://code.launchpad.net/~mars/+junk/geany-python-bindings.
> I've put my code up at https://github.com/codebrainz/geanypy.The README file
> explains the concept pretty well I think and the code should be easy to
> follow.
> The majour problem with this code right now is the Python ctypes bindings
> that I managed to mush out of a couple of auto-generator scripts (h2xml &
> xml2py which come with ctypeslib). To put it bluntly my bindings are crap.
> Maris had a completely different bindings generator which might be (MUST be)
> better, but I couldn't figure out how to generate the bindings. Maris (or
> anyone else in the know), if you're on the mailing list, it would be awesome
> if you could give me a little help with generating your bindings.
> Ultimately, the ideal approach would be to do the bindings in Cython, which
> in my opinion is a far superior way of doing it since it's faster and more
> natural for a Python programmer to use than ctypes. I'm not positive, but I
> think it
> would require having a shared library for the plugin API in order to link
> with the C code generated by Cython, I haven't gotten this far yet.

WARNING, I'm not an expert on this by any means & maybe a bit out of
date since its a while since I did any Python embedding

I think if you declare all the Geany API functions external in Cython
and follow the Pyrex recipe for embedding python (but using
plugin_init instead of main) you don't need a dll of Geany.  Warning
this may negate some of the work you've already done.

> As it stands now, the code works, loads the plugins, passes pointers to the
> 3 structures of GeanyPlugin, GeanyData, and GeanyFunctions, which can be
> accessed through some hackery to dereference the pointers in Python.
> I wanted to get the opinion of some real programmers about this code and
> maybe some ideas about how to get the required data into a usable Pythonic
> API.

Cython is supposed to handle macro definitions (though I never tried)
so it should work with GeanyFunctions as individual functions because
of geanyfunctions.h
GeanyData should work as Python structures

These should allow you to write C code in Python ie not Pythonic or
OO.  Then think about nicer interfaces :-)


Any input or feedback anyone can provide would be very much
> appreciated.
> Cheers,
> Matthew Brush (codebrainz)
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

More information about the Devel mailing list