You are here: Home Tech libsvm wrapped for egg

libsvm wrapped for egg

by Chris Shenton last modified Nov 11, 2008 07:10 PM
Stop the madness.

We're using libsvm for clarity.classify to do automatic classification of text, with Plone documentation as the first target.


I wasted a day getting a buildout of SWIG trying to strip out everything not python-related, but it still seemed to include the kitchen sink.  Only much later did I realize that SWIG isn't needed unless you were going to extend the python wrapper around the C code: the distribution included a SWIG-generated wrapper that's sufficient.


I then spent a couple days trying to compile libsvm and link it against Python.  This isn't as straightforward as it sounds: you can't link it against (say) your system python but use a custom python for your Plone buildout, or vice versa. On OS X this became a sisyphean task as it's dynamic libraries aren't like other Unixes; futher, even when it could be hacked, at run time it still wanted to use the system's Python Framework, which of course broke.


Finally some suggestions in fora about scientific computing showed the way out: don't compile and link against python, let python do the grunt work.  Creating files with external C definitions was new to us, but  Reed O'Brien came up with the goods, so we've created a tarball which makes it easy.

You can use it to install in your system or custom or virtual python like:

python install

or use it in a buildout like:

parts = libsvm
eggs = libsvm
recipe	= zc.recipe.egg
eggs	= libsvm
find-links =
index	=

I expect the same approach can be taken for other C-based code, like liblinear

Share this: