This bash script downloads, builds and installs a particular version of python in the location of your choice without requiring root permissions. It also creates a virtual environment that you can activate to use it. It is licensed under the terms of MIT open source license.
This script makes it easy to install multiple versions of python for staging tests (i.e., tests that you would want to run before installing the new version into production).
You can download it from http://projects.joelinoff.com/pybld/pybld.sh.
I have only tested it on CentOS linux and Mac OS X.
Here is how you would download and run it for a very simple case.
$ mkdir -p ~/work/python/2.7.10
$ cd ~/work/python/2.7.10
$ wget http://projects.joelinoff.com/pybld/pybld.sh
$ chmod a+x pybld.sh
$ (time ./pybld.sh -v 2.7.10) 2>&1 | tee log
$ # Now run it in the virtual environment.
$ python --version
$ pip install pycrypto
$ pip install netaddr
>>> import Crypto
>>> import netaddr
The script has the following options.
|–build-dir <dir>||-b <dir>||The build directory. It can be deleted after successfully installing python.|
|–help||-h||This help message.|
|–release-dir <dir>||-r <dir>||The release directory (contains bin/python).|
|–test||-t||Test the installation. Be careful, this substantially increases the installation time and may result in false positives.|
|–venv-dir <dir>||-e <dir>||The virtualenv directory (contains bin/activate).|
|–version <version>||-v <version>||The python version to install. An example would be “2.7.10”.|