While evaluating distributed version control systems (DVCSs), one of the initial challenges was getting Git, Mercurial, and Bazaar installed on Mac OS X 10.5, Leopard. At first I tried MacPorts, but that really gave me a headache. Read on for how I installed them.

My Problems with MacPorts

I ran into a couple issues with MacPorts. It wouldn’t install Git or Bazaar for me. I don’t remember the details, but at some point, the installation would bail with an error. But even if it did work, installing via MacPorts can be unnecessarily time consuming. You see, MacPorts doesn’t rely on any software already on your system. Installing a Perl application? It downloads and installs it’s own version of Perl. Never mind that Leopard includes a very recent version of Perl. Same goes for Ruby and Python applications.

So how does this affect the DVCSs? Well, Mercurial and Bazaar are both written in Python. Installing these via MacPorts requires downloading a fresh Python interpreter even though Leopard ships with a perfectly functional Python 2.5. Git is even worse. It has dependencies on all sorts of packages like curl, expat, Perl, and Open SSH. Again, Leopard has fully functional versions of all of these. Also, git-svn has a dependency on Subversion, which has it’s own slew of dependencies. Of course, Leopard ships with a recent version of Subversion, along with bindings to Perl, Python, and Ruby, so none of this is necessary.

The end result is that you should probably just avoid MacPorts for these guys on Leopard, at least for now. Even if you don’t run into the installation errors, you’ll save yourself a lot of time by hand installing them. Maybe Fink is better, but I generally avoid Fink.

Installing Mercurial

I’ll start off with Mercurial, as that’s what I’m using. Since Mercurial is a Python package, the easiest way to install is to use Easy Install. Easy Install did not ship with Mac OS X 10.4, but it does ship with Leopard. Unfortunately, Easy Install and Mercurial do not play nice together (see Issue 799). Instead, you have to download the package and follow their Unix instructions. This basically boils down to:

% make
% sudo make install

You can install into a separate prefix by using PREFIX during installation:

% sudo make install PREFIX=/usr/local/encap/mercurial-0.9.5

And you can even install in your home directory, if you don’t want a system install or don’t have admin privileges. See the Unix instructions for details.

If you install in the default location, it’ll be in /usr/local/bin. While this should be in your path, it also adds Python libraries at:

/usr/local/lib/python2.5/site-packages

This will not be in your Python path. You can add this to your PYTHONPATH environment variable, but I found it easier to add a path configuration file. This will add that directory to Python’s default path:

% cat /Library/Python/2.5/site-packages/usr-local.pth
/usr/local/lib/python2.5/site-packages

It may be bad form to create path configuration files, and some Python expert may slap me for it, but it seems to work.

Installing Git

Installing Git from source is very easy. It’s the standard three-step build:

% ./configure
% make
% sudo make install

To install somewhere other than /usr/local, use the --prefix configure option:

% ./configure --prefix=/usr/local/encap/git-1.5.3.7

This will not install the man pages, though. Getting the dependencies necessary to generate the man pages is a bit of a pain, so I recommend downloading a pre-built package, i.e. one of the git-manpages tarballs from their download section.

Installing Bazaar

Bazaar is also Python, but it installs just fine with Easy Install:

% sudo easy_install bzr

This creates an egg in /Library/Python/2.5/site-packages and installs the main binary in /usr/local/bin.

If you want to push and pull using SFTP (which you probably will), you’ll need to install the Paramiko library, too. Again, you can do this with Easy Install:

% sudo easy_install paramiko

And that’s it! You should now have Mercurial, Git, or Bazaar installed on your Leopard system.