Skip navigation

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.

Creation
export CDIR=/opt/python-2.6
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
cd Python-2.6.*
./configure --prefix=$CDIR
make
make install
cd ..

# install setuptools (easy_install)
wget http://pypi.python.org/packages/2.6/s/setuptools/ (get your own link)
PREV_PATH=$PATH
PATH=$CDIR/bin:$PATH
sh setuptools-*.egg
PATH=$PREV_PATH

# install the coveted mysql-python package
wget http://downloads.sourceforge.net/project/mysql-python/ (get your own link)
tar xf MySQL-python-*.tar.gz
cd MySQL-python-*
$CDIR/bin/python setup.py build
$CDIR/bin/python setup.py install
cd ..

tar -czf python-2.6.tgz $CDIR

Deployment
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 $CDIR/bin/python script.

Issues
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.

wget http://www.zlib.net/zlib-1.2.3.tar.bz2
tar -xjf zlib-1.2.3.tar.bz2
cd zlib-1.2.3
./configure
make
make install
cd ..

wget http://www.openssl.org/source/openssl-0.9.7a.tar.gz
tar -xzf openssl-0.9.7a.tar.gz
cd openssl-0.9.7a
./config
make
make install
cd ..

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.

wget http://dev.mysql.com/get/Downloads/MySQL-4.1/MySQL-devel-4.1.22-0.glibc23.i386.rpm/from/http://mirror.services.wisc.edu/mysql/
yum install Mysql-devel*

About these ads

One Trackback/Pingback

  1. [...] Python 2.6+MySQL for CentOS/RedHat/Fedora [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.