install pypy

  • wget
  • bunzip2 pypy-2.3.1-linuxx8664-portable.tar.bz2
  • tar -xvf pypy-2.3.1-linuxx8664-portable.tar
  • mv pypy3-2.3.1-linuxx8664-portable pypy-2.3.1
  • ln -s pypy-2.3.1/bin/pypy /usr/bin/pypy

install system enviaronment

  • yum install --enablerepo=epel libev.x86_64
  • yum install --enablerepo=epel libev-devel.x86_64

must add --enablerepo=epel when install libev on amazon ec2,because there is not libev source in ec2's yum.

if the libev can not install. you can make it by yourself.

install system enviaronment by yourself

  • wget
  • tar -xvf libev-4.15.tar.gz
  • cd libev-4.15
  • ./configuration
  • make
  • make install

creat the pypy virtual enviaronment for development

  • cd pypy-2.3.1
  • bin/virtualenv-pypy ~/PypyEnv
  • cd ~/PypyEnv
  • source bin/activate
  • pip install gevent
  • pip install git+git://
  • pip install cffi
  • pip install git+git://
  • export GEVENT_LOOP=pypycore.loop

If complains it can not locate ev.h it's possible the library search path isn't complete. In that case add the directory containing ev.h to the include_dirs variable in (line 215). The result would look similar to example:


""", includedirs=[includedir,"/usr/include/libev"], libraries=["ev"])

some anontations

  • write the gevent code, must write the code in first line.


# coding: utf8
import sys
import gevent
if "__pypy__" in sys.builtin_module_names:

  def _reuse(self):
  def _drop(self):
  gevent.socket.socket._reuse = _reuse
  gevent.socket.socket._drop = _drop
  • start the gevent server. must run it:


 export GEVENT_LOOP=pypycore.loop