I’m : a web and mobile developer based in the Manning Valley, Australia.

Trac on Apple OS X 10.6 - Snow Leopard

Trac - Integrated SCM and project management Trac is an open-source Python based wiki, issue and project management system. Trac can integrate with many popular version control systems such as subversion, mercurial and git. It's a neat little system that works well for the single developer right through to corporates. I've installed in on my iMac running Mac OS Snow Leopard 10.6.2 and have it integrated with my mercurial repository (sitting on the same host).


The first thing we need to get out of the way is the installation of mod_python. This module is needed to allow us to serve trac from Apache.

    cd ~/Desktop
    svn co
    cd trunk
    ./configure --with-apxs=/usr/sbin/apxs
    sudo make install

Now test the installation by adding the following to /private/etc/apache2/httpd.conf

<Location /mpinfo>
  SetHandler mod_python
  PythonInterpreter main_interpreter
  PythonHandler mod_python.testhandler

Restart apache using sudo apachectl restart and navigate to http://localhost/mpinfo. If all goes well you'll see a "General Information" page - if not check the logs.


With mod_python out of the way we can install trac itself which is amazingly simple:

    sudo easy_install trac

Since I'm using mercurial I'll have to install in support for that too:

    svn co
    cd mercurial-plugin-0.11
    python bdist_egg
    sudo python install

Now decide on a location to save your projects, mine will be in /Library/WebServer/Documents/ so create a folder in there:

    cd /Library/WebServer/Documents/
    sudo mkdir trac-projects
    sudo chown -R www:www trac-projects

When using trac-admin to setup a new project you can use "hg" for the version control and then point it to the path of your mercurial repository. Remember that if you do encounter any strange errors the first thing to do is to ensure that the Apache user (www) has access to the files. So perform the chown above on the trac-projects folder and try again.

Integration with trac and mercurial:

Using the code linked to from download into /usr/local/lib/python2.6/site-packages

Then in the .hgrc file for your project add the following:

changegroup = python:trachook.hook

root = /Library/WebServer/Documents/trac-projects/my_project_folder
url = https://url/to/my/project/
    cd /Library/WebServer/
    sudo mkdir .python-eggs
    sudo chown www:www .python-eggs
    sudo chmod -R 777 .python-eggs

But now we're stuck with the following:

    $ hg push
    pushing to https://
    searching for changes
    adding changesets
    adding manifests
    adding file changes
    added 1 changesets with 1 changes to 1 files
    error: changegroup hook raised an exception: 'str' object is not callable

UPDATE: I logged a ticket for this issue and Jacek Roszkowski came along with the perfect solution. Grab his forked version from which works perfectly.

Since things were now communicating with trac I started to get this error "Unexpected error while processing ticket ID 7: [Errno 8] nodename nor servname provided, or not known". Turns out I had the wrong SMTP settings in my projection configuration file (/Library/WebServer/Documents/trac-projects/myproject/conf). A quick edit later and I'm now getting email notifications.

Thanks Jacek!