MacPorts + Virtualenv + Gevent をインストール

MacPorts で Virtualenv で環境作って pip で Gevent をインストールした際のメモ。

$ mkvirtualenv sample
$ mkdir sample
$ cd sample
$ pip install gevent
略
running build_ext

building 'gevent.core' extension

creating build/temp.macosx-10.8-x86_64-2.7

creating build/temp.macosx-10.8-x86_64-2.7/gevent

/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c gevent/core.c -o build/temp.macosx-10.8-x86_64-2.7/gevent/core.o

In file included from gevent/core.c:253:

gevent/libevent.h:9:10: fatal error: 'event.h' file not found

#include "event.h"

         ^

1 error generated.

error: command '/usr/bin/clang' failed with exit status 1

エラーが出るので、ヘッダへのパスを設定する

$ export C_INCLUDE_PATH=/usr/include:/usr/local/include:/opt/local/include
$ pip install gevent
略
Successfully installed gevent greenlet
Cleaning up...

入ったか確認する。

$ python
Python 2.7.3 (default, Oct 25 2012, 02:20:41) 
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
>>> 

入った。