pythonz makes it easy for you to compile and install different Python versions either system-wide or per user. It supports installing CPython, Stackless, PyPy and Jython.
It's really easy to install pythonz, to install it for your user (that is, in your $HOME) just do as follows:
curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash
After that add this to your
[[ -s $HOME/.pythonz/etc/bashrc ]] && source $HOME/.pythonz/etc/bashrc
Before building Python, you might want to install some optional dependencies, for functionality that is often expected to be included in a Python build (it can be a bummer to discover these missing and have to rebuild your python setup). These include the following, ordered by (very roughly guessed) probability that you will need them (names may differ in your system package manager):
- libz-dev (or zlib)
Once pythonz is installed you can go ahead and install some Python versions:
pythonz install 2.7.3 pythonz install -t stackless 2.7.2 pythonz install -t jython 2.5.2 pythonz install -t pypy --url https://bitbucket.org/pypy/pypy/downloads/pypy-1.8-osx64.tar.bz2 1.8
mkvirtualenv -p ~/.pythonz/pythons/CPython-2.7.3/bin/python cpython272 && deactivate mkvirtualenv -p ~/.pythonz/pythons/Stackless-2.7.2/bin/python stackless272 && deactivate mkvirtualenv -p ~/.pythonz/pythons/Jython-2.5.2/bin/python jython252 && deactivate mkvirtualenv -p ~/.pythonz/pythons/PyPy-1.8/bin/python pypy18 && deactivate
Then you can use
deactivate as usual.