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
{{{ 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 pypy
# Run the below commands. You can replace `–opt=jit` with a different [[|optimization level]]
{{{ lang=bash
cd pypy/pypy/goal/
sudo python ../../rpython/bin/rpython –opt=jit
# Download and install python-setuptools
{{{ lang=bash
sudo wget
sudo ./pypy-c
# 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`
* Enter the PyPy shell with `pypy`
* Install libraries for PyPy with `easy_pypy package_name`






Leave a Reply

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