Upgrade Trac - Interspike Codex

Upgrade Trac

Contents

Upgrading Trac 0.11.x to 0.12.x on CentOS 5.5

This page describes how to upgrade Trac from 0.11.2.1 to 0.12.1 on a CentOS 5.5 server installation.

Instructions for upgrading are available here and should be followed as closely as possible.

Easy Install

In reality, using a program called easy_install, it should be a piece of cake to upgrade or install Tra. But If you forgot about it because you haven't worked with it in a couple years, easy_install handles a lot of the work associated with installing and upgrading stuff.

It has lots of options, one of particular importance is a parameter that tells it to always unzip eggs. This is important because the module that allows Apache to access the Python site packages cannot access an egg file directly. The egg file is basically a library or jar file. In order for the Apache mod_python module to work properly the egg needs to be cracked right where it is, creating a directory next to the egg file itself.

Upgrade Trac

The command to upgrade:

# easy_install --upgrade --always-unzip Trac==0.12.1
Searching for Trac==0.12.1 
Reading http://cheeseshop.python.org/pypi/Trac/
Reading http://trac.edgewall.org/
Reading http://trac.edgewall.org/wiki/TracDownload
Reading http://cheeseshop.python.org/pypi/Trac/0.12.1
Best match: Trac 0.12.1
Processing Trac-0.12.1-py2.4.egg
Adding Trac 0.12.1 to easy-install.pth file
Installing trac-admin script to /usr/bin
Installing tracd script to /usr/bin

Update Projects

If the upgrade goes well, next you need to update all trac projects, usually located under /opt/trac/project-name.

# trac-admin /opt/trac/interspike upgrade

Sync Subversion

If you're using Subversion with a Trac project, you'll want to tell it to refresh itself:

# trac-admin /opt/trac/interspike resync

Gotchas

I did the upgrade without the "always unzip" option first (not knowing about it or that I even needed it) and it downloaded the egg and pretended everything was going to be alright in the world. But it wasn't. I couldn't reach any of my Trac projects through Apache.

After learning of the option, I kept trying it but it wasn't working. I didn't know how to unzip the egg it downloaded and I was still receiving an http 500 error in my Apache logs with an error saying the trac module wasn't available.

Directory and File

After downloading the zipped egg using the easy_install line above, my directory structure looked like this:

drwxr-xr-x  4 root root    4096 Jan  5  2009 Trac-0.11.2.1-py2.4.egg
-rw-r--r--  1 root root 1614490 Jan 23 07:22 Trac-0.12.1-py2.4.egg

Trac thinks it's been upgraded to 0.12.1 but there is no directory like there is for the previous version. If my version of Apache and mod_python need a directory to match the egg, then all will be good. Maybe there is a way to unzip an egg but I'm new to Python and didn't figure out an way to do it to the file itself so I deleted the newest egg file and tried again.

After running the full upgrade command with the unzip line, my directory looks like this:

# /usr/lib/python2.4/site-packages
drwxr-xr-x  4 root root    4096 Jan  5  2009 Trac-0.11.2.1-py2.4.egg
drwxr-xr-x  5 root root    4096 Jan 23 10:13 Trac-0.12.1-py2.4.egg
-rw-r--r--  1 root root   13075 Jan 23 13:52 TracCustomFieldAdmin-0.2.5-py2.4.egg
-rw-r--r--  1 root root   90546 Jan 23 13:57 TracDateField-1.0.1-py2.4.egg

Because I hadn't removed the original egg, it wasn't working. Notice it didn't leave an egg that matches the new directory. Also notice the two sweet plugins I installed later.

The error in my Apache log looked like this:

PythonHandler trac.web.modpython_frontend:   File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 461, in import_module\n    f, p, d = imp.find_module(parts[i], path)
PythonHandler trac.web.modpython_frontend: ImportError: No module named trac

Hopefully this helps someone else someday.

See Also