pyeventをインストールしてみる

f:id:raydive:20080913190053p:image
Eventlet/Documentation - Second Life Wiki


ここを調べている際にpyeventなるものがあるらしいということでMacOSX10.5にてインストールを試みた。

インストール!

f:id:raydive:20080913190052p:image
pyevent - Google Code


適当にダウンロードしてきて、gzipで開ける。

[bash3.2.39]:[~/usr/local/src]
>>$ tar xvzf /Volumes/Sirius/Download/2008-09-13/pyevent-0.3.tar.gz 
pyevent-0.3/
pyevent-0.3/CHANGES
pyevent-0.3/CVS/
pyevent-0.3/CVS/Entries
pyevent-0.3/CVS/Repository
pyevent-0.3/CVS/Root
pyevent-0.3/event.c
pyevent-0.3/event.pyx
pyevent-0.3/LICENSE
pyevent-0.3/Makefile
pyevent-0.3/README
pyevent-0.3/setup.py
pyevent-0.3/test.py

[bash3.2.39]:[~/usr/local/src]
>>$ cd pyevent-0.3/


ここでMakefileがあるので何も考えず、makeと打つと……

[bash3.2.39]:[~/usr/local/src/pyevent-0.3]
>>$ make
python setup.py build
setup.py:29: DeprecationWarning: raising a string exception is deprecated
  raise "couldn't find libevent installation or build directory"
Traceback (most recent call last):
  File "setup.py", line 29, in <module>
    raise "couldn't find libevent installation or build directory"
couldn't find libevent installation or build directory
make: *** [all] Error 1


ふむ、libeventがどこにあるか分からないようだね。(ちなみにlibeventはMacPortsで入れたので/opt/local下にある)
ということでsetup.pyを覗いて少しいじった。
これが修正前で、

elif glob.glob('%s/lib/libevent.*' % sys.prefix):
    print 'found installed libevent in', sys.prefix
    event = Extension(name='event',
                       sources=[ 'event.c' ],
                       include_dirs=[ '%s/include' % sys.prefix ],
                       library_dirs=[ '%s/lib' % sys.prefix ],
                       libraries=[ 'event' ])


こっちが修正後。

sys.prefix = '/opt/local'

#このあたりにいろいろあって……

elif glob.glob('%s/lib/libevent.*' % sys.prefix):
    print 'found installed libevent in', sys.prefix
    event = Extension(name='event',
                       sources=[ 'event.c' ],
                       include_dirs=[ '%s/include' % sys.prefix ],
                       library_dirs=[ '%s/lib' % sys.prefix ],
                       libraries=[ 'event' ])


あまりにdirtyな気がするがmakeは通ったのでOK。とりあえずサイトのサンプルをipythonからたたいてみて動作は確認できた。