Kitware Packages on OS X with Homebrew

Homebrew is a package manager for OS X, which has become very popular in recent years. The homebrew-core repository provides more than 3,500 packages. There are multiple other repositories, like homebrew-science, where you can find tools from the Kitware ecosystem such as the Visualization Toolkit (VTK), the Insight Segmentation and Registration Toolkit (ITK), and Paraview.

This article describes the main principles of Homebrew and discusses its routine usage.


Installing Homebrew is easy. Just use the following:

/usr/bin/ruby -e "$(curl -fsSL"

This command will clone the homebrew-core Git repository to your /usr/local folder and set up Homebrew.

Each package is defined by a Ruby script, called a “formula.” A package repository is called a “tap.” The /usr/local/Library/Taps folder will contain different taps (homebrew-core, homebrew-science, etc.). Each tap contains different formulas. The full list of Homebrew repositories can be found here.

Installing Packages

First, let’s install an awesome tool: CMake.

brew install cmake

CMake will be installed at /usr/local/Cellar/cmake/3.5.2/bin/cmake and symlinked to /usr/local/bin/cmake. You can now run CMake from the command line. Most of the packages have pre-compiled binaries, called “bottles.” The bottles get poured to your computer, so you don’t have to recompile the package.

Now, let’s install ITK. You first need to “tap” the science repository. This will clone the homebrew-science repository to /usr/local/Library/Taps/homebrew/homebrew-science and prepare the formulas for use:

brew tap homebrew/homebrew-science

Then, you can run the following:

brew install vtk

brew install insighttoolkit

VTK and ITK should now be installed on your system.

If you need Python wrappings, use the following commands:

brew install vtk --with-python

hbrew install insighttoolkit --with-python

Useful Commands

The below example for CMake shows how you can get more information about a formula.

Most formulas have install options. The list of options can be found using the brew info [package name] command. While the bottles come with the most sensible options pre-selected, you may want to recompile the package locally with other options. There are few package managers that allow such flexibility!

One of the most frequently used commands is the brew update command. This command will fetch the latest changes from the Git repositories and update all the formulas. The brew upgrade command will remove older packages and install the newest versions.

Of course, you can get more help using man brew  or brew −−help. You can also reference the documentation.

Modifying a Formula

Writing or modifying a formula is very easy. As an example, here is a simplified version of the CMake formula. The full formula (with build options, dependencies, etc.) can be found here.

The syntax is quite self explanatory. There is a short description, a homepage URL, the URL for the source code, and it’s sha256. Then comes the address of the repository for the project. When building the package with brew install cmake –HEAD, the latest version is compiled and installed.

Next comes the bottle block, which defines the binaries that get automatically poured when you install the formula. Homebrew’s policy is to support the last three versions of OS X. At the end comes the install instructions and, finally, a small test block.

Once you are happy with your changes, you may want to share your work. To do so, just fork the right Homebrew Git repository, and submit a pull request. Make sure to read the contributing guidelines carefully before making a submission. There are no specific maintainers for the packages; anybody can make a change. That being said, changes do need to be merged by one of the main Homebrew maintainers.

Some thoughts

The first two main package managers on Mac were Fink (apt-based) and MacPorts. Homebrew was released in 2009, and it has grown at a steady pace since then. I will not make a comparison between the three package managers, as each of these has advantages and disadvantages. I will, however, list some advantages of Homebrew.

Homebrew has organically grown in a very open nature. All of the source code for Homebrew is hosted on GitHub, and everybody is free to participate. The success of Homebrew may also be linked to the success of GitHub. People are used to employing open pull requests on GitHub for their favorite open-source projects. This familiarity has facilitated the update of Homebrew, as the workflow is the same.

In addition, Homebrew does not need to run commands with Sudo. The logic here is that you should be able to install whatever application or library you want without compromising the security of your Mac. This is why Homebrew installs everything to /usr/local/ . (You can select a different location, however, if you choose). No files will be installed outside of the Homebrew prefix. Also, this folder is already in your PATH.

Another point is that there is quite a strict policy regarding patches. Patches are tolerated, but they need to be pushed upstream first. This has led to a huge effort to keep the formulas patch free. The packages are managed in a very dynamic way, as they tend to be updated quite rapidly, when new versions come out. The frequent nature of these updates has the disadvantage that you need to keep up with the new incoming versions. Nevertheless, you can “pin” a formula and keep the old version.

For example, the download statistics for CMake (August 2015 to May 2016) indicate that most people have an up-to-date system. This is also true for a lot of other packages.

cmake download statistics (homebrew 2015-2016)

You may also note that there is a very interesting project, which brings Homebrew to Linux, called Linuxbrew. It’s worth giving it a try.


Homebrew has proven to be a reliable way to install libraries on Mac OS X for years. The addition of CMake, VTK, ITK and Paraview was straightforward, and the community is keeping an eye out to make sure that they are up to date. One project, for example, aims to provide the ITK package with binaries that contain the wrapped interfaces for Python, so you don’t have to compile it from source.

Enjoy Homebrew and the Kitware packages!

About Michka Popoff

I have a PhD in Physics (Université Lille 1, France). My speciality is Atomic Force Microscopy. In 2015 I started working as a software developer in Berlin (Germany). I am an active contributor to many open source projects during my free time. Why? Because it's fun!

4 Responses to Kitware Packages on OS X with Homebrew

  1. iCFD says:

    Shouldn’t it be: brew install insighttoolkit ?

  2. Pawel Czech says:

    I installed everything, but in python. Import vtk, do not work.

Questions or comments are always welcome!