Saturday 16 April 2011

Building Python2.5 for Ubuntu 11.04

I run a few appengine instances and so I was quite disappointed after upgrading to Ubuntu 11.04 to find no pre-packaged versions of python2.5 (the version on which appengine is currently based). Python 2.7 is not compatible with various parts of the appengine dev server. After a bit of playing around this is the easiest way I found to get everything working that I needed. YMMV.

edit the top of dev_appengine.py and replace
#!/usr/bin/env python


with
#!/usr/bin/env python2.6


Python 2.6 is not ideal but it seems to do the job. If you want to go the extra mile (as I did) and install Python 2.5.5, you need to manually add ssl and address some bad assumptions python makes about sqlite3's library locations...


  1. apt-get install libssl-dev libsqlite3-dev.
  2. Edit Modules/Setup.dist and uncomment the _ssl and zlib lines.
  3. Edit setup.py and modify it to look like this:
    sqlite_dirs_to_check = [
    os.path.join(sqlite_incdir, '..', 'lib64'),
    os.path.join(sqlite_incdir, '..', 'lib'),
    os.path.join(sqlite_incdir, '..', 'lib', 'x86_64-linux-gnu'),
    os.path.join(sqlite_incdir, '..', '..', 'lib64'),
    os.path.join(sqlite_incdir, '..', '..', 'lib'),
    os.path.join(sqlite_incdir, '..', '..', 'lib', 'x86_64-linux-gnu'),
    ]

  4. make clean && ./configure --prefix=/usr/local/python2.5 && make
  5. sudo make install
  6. ln -s /usr/local/python2.5/bin/python2.5 /usr/bin
  7. Change dev_appengine.py to refer to python2.5

Good luck!

2 comments:

  1. Thank you for the good entry!

    6.ln -s /usr/local/bin/python2.5 /usr/bin

    is

    6.ln -s /usr/local/python2.5/bin/python2.5 /usr/bin

    isn't it?

    ReplyDelete
  2. Argh. Thanks, you're absolutely right. Fixed.

    ReplyDelete