This is how I created a tarball that, when extracted, gives a fully functioning install of python 2.6 w/ mysql – while leaving all of the original binaries in place. The destination of the tarball must be decided at compile time. You may need to recreate the tarball if any of the software packages this is based on (the *-devel packages found below) are upgraded.
The creation process will modify the build server, though the resulting tarball will be completely clean (can be untarred into any similar server with identical software versions and file locations without modification). You may want to wipe your environment after successfully testing deployment.
mkdir py-tmp && cd py-tmp
# get needed libraries
# if any of these fail to install for whatever reason, you will need to grab the source for the closest available version to what is running on your system, and install it manually into its standard location (specific examples found below).
yum install -y wget zlib-devel openssl-devel readline-devel mysql-devel gcc-c++
# now for Python itself
wget http://www.python.org/ftp/python/ (get your own updated link)
tar xf Python-2.6.*.tgz
# install setuptools (easy_install)
wget http://pypi.python.org/packages/2.6/s/setuptools/ (get your own link)
# install the coveted mysql-python package
wget http://downloads.sourceforge.net/project/mysql-python/ (get your own link)
tar xf MySQL-python-*.tar.gz
$CDIR/bin/python setup.py build
$CDIR/bin/python setup.py install
tar -czf python-2.6.tgz $CDIR
tar -xzf python-2.6.tgz -C /
To use this python binary, you can modify your $PATH, adding $CDIR/bin before /usr/bin or wherever your other version is installed. To make a python script use this version, either specify the full path on the scripts #! line, or run
If any of the libraries fail to install (possibly due to crufty servers), you will need to install them manually to their standard location. Here are some examples of what I've had to do. Be sure to grab the same version of the software as is already installed.
tar -xjf zlib-1.2.3.tar.bz2
tar -xzf openssl-0.9.7a.tar.gz
Here is something quite important: if you cannot install mysql-devel, I recommend just grabbing the devel rpm from mysql.com. Be sure that the mysql version matches as closely as possible to that installed in your system (the version should be spit out when you try to run yum install mysql-devel). Also, the glibc version must match your system exactly.
yum install Mysql-devel*