Peter's Blog

Redefining the Impossible

Freezing my Gems Off


I have a two and a half year old python/turbogears web application that is fairly mission critical yet thoroughly software rotted. It was built with a delicate mix of python eggs running on python 2.4 and ubuntu hardy. Any attempt to upgrade any part of it yeilded obscure errors.

A recent disk failure on another server had me worrying about this state of affairs: how to migrate it to a new server? Well, an idea hit me: copy all the python2.4 site-packages to the applications own directory on the new server and set it's path up to use them rather than try to install the correct hotch-potch of system libraries.

This didn't work immediately as the site-packages directory was full of broken symbolic links to the python setup tools and mysql gems. Installing these from ubuntu packages didn't work because the installation directories had changed between ubuntu hardy and jaunty.

In the end I avoided the need for python setup tools by unpacking all the python eggs, including the mysql stuff, into bare sets of python source. This worked surprisingly well, problem solved.

Now I had a working blob of code and libraries that only needed python2.4 and it's standard libraries to work. I quickly shoved it into git in it's functional glory.

The experience made me appreciate the concept of freezing gems with a rails app:

  • everything goes into git with minimal external dependencies
  • no worry that (for example) the gem for a specific version of mysql is no longer available anywhere when redeploying (the sqlite gem on windows is precarious).
  • quicker redeploy on a clean server: no run server/get missing gem error/install gem/ run server... loop.

I find that every rails update tends to break at least one thing and I only discover them when I am doing a panicy server rebuild.


Filed under: python ruby

Sorry but comments on this post are now closed.