Compiling PyPy From Source

[[http://pypy.org/|PyPy]] is significantly faster when compared against the default [[http://en.wikipedia.org/wiki/CPython|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 [[http://www.riverbankcomputing.com/software/pyqt/download|PyQt4]] and [[http://trac.edgewall.org|Trac]]. For more specific benchmarks, see [[http://speed.pypy.org/|PyPy’s Speed Center]].

# First we will need all the dependencies
{{{ lang=bash
# 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
{{{ lang=bash
cd /opt
sudo hg clone https://bitbucket.org/pypy/pypy pypy
}}}
# Run the below commands. You can replace `–opt=jit` with a different [[http://doc.pypy.org/en/latest/config/opt.html|optimization level]]
{{{ lang=bash
cd pypy/pypy/goal/
sudo python ../../rpython/bin/rpython –opt=jit targetpypystandalone.py
}}}
# Download and install python-setuptools
{{{ lang=bash
sudo wget http://python-distribute.org/distribute_setup.py
sudo ./pypy-c distribute_setup.py
}}}
# Create symlinks in `/usr/bin` for easier access
{{{ lang=bash
sudo 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`


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *