Compiling PyPy From Source
PyPy is significantly faster when compared against the default CPython interpreter. For the most part, this interpreter functions the same way that CPython does, and most libraries will run with no issues. In my testing, PyPy was 5-10 times faster than CPython and I was able to install/use every library other than PyQt4 and Trac. For more specific benchmarks, see PyPy’s Speed Center.
- First we will need all the dependencies
# Debian/Ubuntu sudo apt-get install \ gcc make python-dev libffi-dev libsqlite3-dev pkg-config \ libz-dev libbz2-dev libncurses-dev libexpat1-dev \ libssl-dev libgc-dev python-sphinx python-greenlet mercurial # RHEL/CentOS/Fedora sudo yum install \ gcc make python-devel libffi-devel lib-sqlite3-devel pkgconfig \ zlib-devel bzip2-devel ncurses-devel expat-devel \ openssl-devel gc-devel python-sphinx python-greenlet mercurial
- Change to sources directory and checkout repo
cd /opt sudo hg clone https://bitbucket.org/pypy/pypy pypy
- Run the below commands. You can replace
--opt=jit
with a different optimization levelcd pypy/pypy/goal/ sudo python ../../rpython/bin/rpython --opt=jit targetpypystandalone.py
- Download and install python-setuptools
sudo wget http://python-distribute.org/distribute_setup.py sudo ./pypy-c distribute_setup.py
- Create symlinks in
/usr/bin
for easier accesssudo ln -s /opt/pypy/pypy/goal/pypy-c /usr/bin/pypy sudo ln -s /opt/pypy/bin/easy_install /usr/bin/easy_pypy
- Run python scripts in PyPy with
pypy script_path.py
- Enter the PyPy shell with
pypy
- Install libraries for PyPy with
easy_pypy package_name