Homebrew and pyexiv2

My experience with package managers in Linux, apt in particular, was so good that when I moved back to the Macintosh several years ago, I figured I’d have no trouble installing almost any command-line program I ran across. Things didn’t turn out that way.

I started with Fink. It seemed to work well at first, but then I noticed it was installing libraries that I knew were already on the computer. Fink put all its software in /sw or /opt/sw (I can’t remember which), and that’s where it expected to find all the support libraries.1 When it didn’t find them there, it would download and install new versions. I didn’t like the duplication, but disk space wasn’t at a premium, so I let it go. Later, though, I started having problems with packages not installing correctly, and I couldn’t figure out why. It may have been more my fault than Fink’s, but whatever the reason, I had to stop using Fink.

I moved on to MacPorts, which was called DarwinPorts at the time. It differed from Fink in that it compiled the software it downloaded rather than installing precompiled packages. What soured me on MacPorts was unnecessary dependencies. Some packages took forever to install because the dependency chain just kept growing and growing with libraries that I couldn’t believe were needed. After a couple of instances in which I had to abort installation because I wasn’t sure they’d finish, I quit MacPorts.

So when Homebrew came out, I resisted. Everyone raved about it, but I wouldn’t install it. No, I said, I’ve been burned twice by these package managers—I’m not going to try another one. I just kept downloading gzipped tarfiles and compiling from scratch, figuring out the minimum dependencies on my own and installing them by hand, too. That can be very satisfying when it works. You really feel like a master of your machine. But sometimes the little tricks needed to get a compilation to work eluded me.

Last night, for example. I wanted to install the pyexiv2 library, a Python EXIF library that appears to be more capable than the one I’ve been using (which has failed to find certain EXIF tags in some files). Pyexiv2 is a wrapper around the C++ exiv2 library and needs the Boost library and SCons utility for installation. The dependencies proved to much for me.

I held my breath and installed Homebrew. There’s no recipe for installing pyexiv2 through Homebrew, but I was able to

brew install exiv2
brew install scons
brew install boost

with no trouble, which was a big step forward. Then I found this script by Joel Watts and was able to make a change or two to fit my situation. I downloaded and expanded the pyexiv2 source tarball, cd’d into its directory to add a line to its SCons script via

echo "env['FRAMEWORKS'] += ['Python']" >> src/SConscript


scons BOOSTLIB=boost_python-mt
scons BOOSTLIB=boost_python-mt install

built and put all the pyexiv2 files in place. The only problem was that Python didn’t understand the presence of one library file, libexiv2python.dylib. It wanted to see libexiv2python.so instead. A quick symbolic link

sudo ln -s /Library/Python/2.7/site-packages/libexiv2python.dylib /Library/Python/2.7/site-packages/libexiv2python.so

fixed that problem, and now I can import pyexiv2 with no errors. I have a few projects I plan to use it in, including an upgrade to my canonize photo renaming utility and some new Flickr API scripts.

So far, then, I have to say I was wrong and everyone else was right about Homebrew. I hope they stay right. It’d be nice to have a trustworthy package manager.

  1. Fink may be different now.