Notice: I have neither posted nor updated any content on this blog since the mid 2010's. (😱) Please check out the homepage and my bio, for more recent things. Below is the original content of this post:

PyPy on Heroku

WARNING: This is an old post from 2012. The information here is likely incredibly out of date. Proceed at your own risk.


A few people (including the main @Heroku account on Twitter) have mentioned that I’ve thrown together a working Heroku buildpack for PyPy. (And hey, PyPy 1.8 just dropped last Friday so you should check that out.)

I noticed a couple other attempts that were broken (with an 'import site' failed error) and did some sleuthing on my own deployed-but-broken PyPy/Heroku site: did you know you can run arbitrary commands by using heroku run? I dug around (via heroku run "ls -la *") and tinkered with a buildpack of my own and discovered that the include dir was being symlinked (not actually copied) and the lib-python and lib_pypy directories contained symlinks rather than actual .py files. (This is possibly an issue with virtualenv --relocatable and PyPy.)

I fixed the buildpack by removing those directories and copying them manually after the virtualenv is set up.

(Aside: I’ve been toying with Heroku in my spare time for a mere couple weeks now, but the Cedar Buildpack system is a really awesome concept and really caught my eye: you can essentially use them to deploy your own arbitrary projects and languages to the Cedar stack.)


In any case, this buildpack is more or less a drop-in replacement for the default Heroku one. When creating a Heroku app, you can enable it like this:

heroku create --stack cedar --buildpack git://github.com/mtigas/heroku-buildpack-pypy.git

Or, modify an existing Python/Heroku app by using:

heroku config:add BUILDPACK_URL=git://github.com/mtigas/heroku-buildpack-pypy.git

…and then re-deploying your app (by pushing).

Enjoy your easy to set up, cloud-hosted PyPy!