Trac on Apple OS X 10.6 - Snow Leopard
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).
mod_python:
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 https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk
cd trunk
./configure --with-apxs=/usr/sbin/apxs
make
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
</Location>
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.
trac:
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 http://svn.edgewall.com/repos/trac/sandbox/mercurial-plugin-0.11
cd mercurial-plugin-0.11
python setup.py bdist_egg
sudo python setup.py 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 http://swag.dk/blog/2008/10/13/mercurial-trac-commit-hook/ download into /usr/local/lib/python2.6/site-packages
Then in the .hgrc file for your project add the following:
[hooks] changegroup = python:trachook.hook [trac-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 http://bitbucket.org/jarosz/mercurial-trac-hook/ 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!