Friday, October 2, 2015

Building Python GEvent on OSX 10.10.5

Download Source Files

You will need the following sources:
  • openssl-1.0.2d.tar.gz            (
  • libevent-2.0.22-stable.tar.gz
  • gevent-1.0.2.tar.gz
Place the tar balls in /usr/local/src

Extract the tar-balls

cd /usr/local/src

tar -zxf openssl-1.0.2d.tar.gz
tar -zxf libevent-2.0.22-stable.tar.gz
tar -zxf gevent-1.0.2.tar.gz

Build the Dependencies

cd openssl-1.0.2d
./Configure darwin64-x86_64-cc shared
make test
sudo make install
cd ..

cd libevent-2.0.22-stable
export CFLAGS="-I/usr/local/ssl/include"
export LDFLAGS="-L/usr/local/ssl/lib"
make verify                      # Verify takes about 5 minutes (okay to skip)
sudo make install
cd ..

Setup Python, Pip and Virtual Environment

# Make sure your using python 2.7.x (not 3.x)
# I install python 2.7.10 from so that I have pip
# Add the new python to your path

export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/2.7/bin
sudo pip install --upgrade pip

# Setup virtual environment wrapper

sudo pip install virtualenvwrapper
export WORKON_HOME=~/Envs
mkdir -p $WORKON_HOME
source /Library/Frameworks/Python.framework/Versions/2.7/bin/

Finally, Build GEvent

cd gevent-1.0.2
mkvirtualenv gevent-build
pip install greenlet
export CFLAGS="-I/usr/local/include -L/usr/local/lib"
curl | patch -p0
python bdist_wheel
python install

Re-Use GEvent in another Virtual Environment

#If you want to install gevent into another virtual env do:

mkvirtualenv MY_NEW_VIRTUAL_ENV
cd /usr/local/src/gevent-1.0.2
python install