Installing gevent on shared hosting server

by Mandar Vaze on January 3, 2012
in Python, tips

Recently, I had to install “gevent” python module on webfaction. Normally, I would install it using “pip install gevent” – Very straight forward. But python gevent module requires libevent library, specifically the .so file. This file normally resides in /usr/lib, but on shared host you do not have permissions to write to this location, hence the normal method wouldn’t work.  The trick is to install the .so in custom location, but more importantly, ask pip to use this non-standard location using –install-option command line option

Here are the steps I followed :

wget https://github.com/downloads/libevent/libevent/libevent-1.4.13-stable.tar.gz
tar xvzf libevent-1.4.13-stable.tar.gz
mkdir ~/externals
cd libevent-1.4.13-stable
./configure –prefix=$HOME/externals/
make
make install
pip install –install-option=”-I$HOME/externals/include” –install-option=”-L$HOME/externals/lib” gevent
In the above steps $HOME is taken only as an example, feel free to install it at other locations, and pass the appropriate path to -I and -L as arguments.
While the example above talks about libevent, This method works well for other software as well.