cmemcache is based on the C library libmemcache, but for some reason the author includes a patch for libmemcache that should be applied before compiling. The only problem is that this patch doesn’t work. After patching, compiling, and installing libmemcache and then installing cmemcache, any attempt to import the cmemcache module in your Python code comes back with this error:
ImportError: /usr/local/lib/libmemcache.so.0: undefined symbol: mcm_buf_len
I’m not the first one experiencing this issue, as can be seen here and here. One of the comments in the second link mentions another patch, which supposedly should work better than the original one. Despite having an icky feeling about it, I went ahead and installed libmemcache with the fishy patch as follows:
wget http://people.freebsd.org/~seanc/libmemcache/libmemcache-1.4.0.rc2.tar.bz2 tar xvfj libmemcache-1.4.0.rc2.tar.bz2 cd libmemcache-1.4.0.rc2/ wget --no-check-certificate https://svn.pardus.org.tr/pardus/devel/programming/libs/libmemcache/files/libmemcache.patch patch -p1 < libmemcache.patch sudo apt-get install automake1.9 ./configure && make sudo make install
The patch modifies the configure.ac file, which make first complained about, so I had to install automake1.9 before running make again. Once libmemcache is installed, cmemcache can be installed:
wget http://gijsbert.org/downloads/cmemcache/cmemcache-0.95.tar.bz2 tar xvfj cmemcache-0.95.tar.bz2 cd cmemcache-0.95/ sudo apt-get install python-dev sudo python setup.py install
I had to install the python-dev package first because cmemcache depends on Python.h provided by that package. Running the test.py test suite after this actually works better than with the official patch earlier, but one test fails even so:
Traceback (most recent call last): File "test.py", line 254, in test_memcache self._test_base(cmemcache, cmemcache.StringClient(self.servers), ok=1) File "test.py", line 132, in _test_base self.failUnlessEqual(len(stats), 1) AssertionError: 0 != 1
That being said, you can test cmemcache manually at this point and it actually seems to work a little bit (memcached should be running on localhost):
>>> import cmemcache >>> c = cmemcache.StringClient(['127.0.0.1:11211']) >>> c.set('testkey', 'testval') 1 >>> c.get('testkey') 'testval' >>>
All things considered, this was a less than convincing experience with cmemcache, and the thought of running an unofficial and undocumented patch for an aging library in a production environment is not altogether appealing.
Update: See also my subsequent attempt of installing libmemcache through apt-get. Not really more successful, but easier at least.