How to Install Subversion for Trac on Mac OS X

Trac is a project management system from Edgewall. It also offers the ability to browse source code and project materials managed by Subversion (svn). This article shows to set up svn support in Trac on Mac OS X.

This article builds on my earlier installing Trac guide. As before, this article assumes you have Xcode and the command line tools installed.

Mac OS X 10.8, aka Mountain Lion, does not include Subversion SWIG support for Python. To enable svn repository browsing in Trac, Subversion SWIG is needed. We need to add this support ourselves.

Build Subversion SWIG-py

It is important to download the appropriate version of Subversion. The version needs to match the version installed on your Mac. Use the svnadmin command to print the version information:

svnadmin --version
svnadmin, version 1.6.18 (r1303927)
    compiled Aug  4 2012, 19:46:53

On Mac OS X 10.8.2 with Xcode 4.5, Subversion v1.6.18 is installed.

Download, build, and install Subversion's SWIG-py component:

curl '' > subversion-1.6.18.tar.bz2
tar -xjf subversion-1.6.18.tar.bz2
cd subversion-1.6.18
./configure --prefix=/usr/local/svn-1.6.18
make swig-py
sudo make install install-swig-py

You will likely see linker, ld, warnings but these do not affect Trac.

With the Subversion SWIG libraries for python installed in /usr/local/svn-1.6.18, we need to tell python where to find them.

Create the text file /Library/Python/2.7/site-packages/svn-python.pth

Set the contents of the svn-python.pth file to:


Enable Subversion in Trac

Within Trac's web interface, log in as an administrator capable user. Browse to Admin > Plugins > Trac 1.0

Subversion plug-ins within Trac

Subversion plug-ins within Trac

Within the plug-in list, enable the following plug-ins:

  • SubversionConnector
  • SubversionMergePropertyDiffRenderer
  • SubversionMergePropertyRenderer
  • SubversionPropertyRenderer

With these plug-ins enabled, click Apply Changes.

Add Repositories

Trac is now able to connect to and interact with Subversion. Browse to Admin > Repositories and add your projects.

You will need to resync with the repositories and set up svn hooks.

If you set up Trac following our installation guide, the bulk resync command will be:

sudo /usr/local/bin/trac-admin /Users/Shared/trac repository resync "*"

Within each svn repository, add a post-commit hook file following the template below:


/usr/local/bin/trac-admin /Users/Shared/trac changeset added "projectname" "$REV"

You can learn more about hooks in the Subversion book.

Congratulations, Trac will now display a Browse Source link and your Subversion repository can be explored using a web browser.

This article was posted in and tagged , , and .

Published by Graham Miln on