Tuesday 30 November 2010

Webfaction: Installing Xapian and python bindings

Xapian Logo

Xapian is the best choice for webfaction (for me) because it has many of the nice features of solr whilst not running like a daemon so it doesn’t use up precious memory. Installing it can be an arse though so I thought I’d document the process.

Download the xapian-core and xapian bindings.

Pretty straight forward stuff.

 mkdir src cd src wget http://oligarchy.co.uk/xapian/1.2.12/xapian-core-1.2.12.tar.gz wget http://oligarchy.co.uk/xapian/1.2.12/xapian-bindings-1.2.12.tar.gz tar -xzvf xapian-core-1.2.12.tar.gz tar -xzvf xapian-bindings-1.2.12.tar.gz 

Install Xapian

We’re in a shared environment so we don’t have permission to install into the system folders. I’m going to install it into $HOME/local/. It’ll take a few minutes so it’s the perfect time to grab a coffee or have an impromptu power move rehearsal

 cd xapian-core-1.2.12 mkdir -p $HOME/local ./configure --prefix=$HOME/local make make install 

Install Xapian Bindings

This is the one that always unsticks me.

I’ll be using python2.6 from a virtualenv so I’m going to activate that one now. If you’re not using a virtualenv then you don’t need to do this. ( my virtual environment is called staging26, your’s will be different)

 workon staging26 

Now for the money shot. It should all go according to plan — no errors.

 cd ../xapian-bindings-1.2.12 ./configure --with-python --prefix=$HOME/local/ XAPIAN_CONFIG=$HOME/local/bin/xapian-config make make install 

Check it

Fire up the python shell and try to import the module

 python -c "import xapian" 

No errors? Bingo

Fancy that.