Junk Food for the Brain

Open Source and Awesomesauce :)

Installing Python 2.7.2 on Centos 5.2

| Comments

Centos / RHEL5 come with Python v2.4.3, which was relased in 2006 and is as ancient as you can get nowdays. Even other application build scripts require Python >= 2.5 for building, e.g node.js & Spidermonkey 1.8.5. :|

This is my attempt at building a base Python distro that sits in /opt/python-2.7.2. My goal is to minimize depending on the installed system developement libraries; As in Enterprise-y environments, ‘polluting’ the standard OS image will result in a visit from the XKCD GOTO Raptor.

tldr; This is the script I created to install Python.

To start, I installed Centos 5.2 with only the groups @core, @base and @development tools. A few Text-Based Internet utilities were also installed for convinience’s sake.

I then downloaded Python 2.7.2 and ran the standard configure-make-make install routine, and got this:

INFO: Can't locate Tcl/Tk libs and/or headers

…Snipped...
Python build finished, but the necessary bits to build these modules were not found:
_bsddb             _curses            _curses_panel   
_sqlite3           _ssl               _tkinter        
bsddb185           bz2                dbm             
dl                 gdbm               imageop         
readline           sunaudiodev        zlib            
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
….Snip…

FML, I knew this was the beginning of a journey into a rabbit hole.

This is the install sequence

sqlite
bzip2
zlib
openssl
ncurses
readline
gdbm
bsddb
python

Some decisions I took:
Not installing the TCL/TK toolkit, as building tk requires X11 libraries which I didn’t install.

The end result was this:

Building dbm using bdb
INFO: Can't locate Tcl/Tk libs and/or headers

Python build finished, but the necessary bits to build these modules were not found:
_tkinter           bsddb185           dl              
imageop            sunaudiodev                        
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

sunaudiodev is is for Sun platforms,dl for 32bit platforms, imageop is deprecated and bsddb185 is undocumented.

What the script does:
* created a directory called src and build.
* Downloads the required libraries and compiles them in build * installs them all in /opt/python-2.7.2 * Removing this should be as easy as rm -rf /opt/python-2.7.2

If you wish to modify the install path, edit the PREFIX option in the script.

References: * andrew.io * Equatorian

Similar Projects that Address this issue (more elegantly) * pythonbrew * pybuild

Comments