These instructions compile a native OS X version of libmagic and the libmagic python binding, which use the system magic database, that live in your home directory, and which cannot be moved around, but which should always be discoverable by applications.
Assumes OS X with Xcode or Xcode command-line tools, not macports or homebrew
To install Xcode command-line tools in recent versions of OS X, open Terminal, type xcode-select --install
and click "Install"
Older versions of OS X may need to manually download disk images of older versions of Xcode and/or the Xcode command-line tools, as various certificates may have expired (e.g. 10.7.4 requires a manual install from the Xcode 4.6.2 command-line tools image)
Download Apple's latest modified file 5.04 (used in 10.7+) from http://opensource.apple.com/tarballs/file/file-47.tar.gz