[sword-devel] Python bindings for libsword with SIP

Troy Melhase troy.melhase at gmail.com
Fri Nov 27 21:37:11 MST 2009


Greetings,

I've created a Python binding for libsword via SIP[1].  The code is here:

    http://github.com/natural/sword-sip

The binding is mostly complete, certainly the larger classes and
methods.  I'd like it if folks who use the SWIG bindings could also
try to build this binding with SIP and send me any feedback, good, bad
or indifferent.

As to why:  SWIG is great for what it does, but what it produces isn't
the most natural for Python  programmers.  My motivation was to
replace code like this:

    >>> install_source.directory = SWBuf("/some/path")

With code like this:

    >>> install_source.directory = "/some/path"

SIP provides this by mapping to and from native python types where
instructed.  I've got it working for SWBuf, ModMap, SectionMap,
ConfigEntMap, etc.

Another minor benefit is size:  the resulting sword.so file is 1454499
bytes on my system, whereas _Sword.so is 1949642.  The SIP bindings
require the SIP runtime, which is another 70k, but that dependency is
shared if your project is already using it (and it's smaller than the
Sword.py helper used by _Sword.so).

troy


[1]  SIP:  http://riverbankcomputing.co.uk/software/sip/



More information about the sword-devel mailing list