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            (https://www.openssl.org/source/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
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"
./configure
make
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 python.org 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/virtualenvwrapper.sh



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 https://gist.githubusercontent.com/dtrott/3168c6138fd27b4e6522/raw/43471b2ac530bcc81ea228f9d64537ab72d6225a/gevent-ev.patch | patch -p0
python setup.py bdist_wheel
python setup.py 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 setup.py install

No comments:

Post a Comment