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 is also available on github: https://github.com/jlinoff/pybld.git
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
$ 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 <output snipped> $ # Now run it in the virtual environment. $ rtf/venv/python2710/bin/activate $ python --version Python 2.7.10 $ pip install pycrypto <output snipped> $ pip install netaddr <output snipped> $ python <header snipped> >>> import Crypto >>> import netaddr >>> quit() |
The script has the following options.
Long Option |
Short Option |
Description |
---|---|---|
–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”. |
Enjoy!