# Homebrew on macos

**URL:** https://discourse.kitware.com/t/homebrew-on-macos/75
**Category:** Build & Install
**Created:** [April 6, 2018, 7:25pm UTC](https://discourse.kitware.com/t/homebrew-on-macos/75 "2018-04-06T19:25:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [April 6, 2018, 7:25pm UTC](https://discourse.kitware.com/t/homebrew-on-macos/75/1 "2018-04-06T19:25:51Z")

</div>

It’s come up that homebrew now only provides python3. Unless you have a previous homebrew python 2.7, there’s no way to build SMTK without building your own python. (The macos-provided python will not work due to security sandboxing that prevents installing new site packages.) TJ has verified the SMTK/CMB superbuild will not build python on macos.

Going forward, should we

- prioritize getting SMTK/CMB to build using python3?
- try to get the superbuild on macos to build python2?
- forcing everyone to build their own python2?

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [April 7, 2018, 8:11pm UTC](https://discourse.kitware.com/t/homebrew-on-macos/75/2 "2018-04-07T20:11:09Z")

</div>

Note that

> **[python-cmake-buildsystem/python-cmake-buildsystem](https://github.com/python-cmake-buildsystem/python-cmake-buildsystem)**
>
> A cmake buildsystem for compiling Python. Contribute to python-cmake-buildsystem/python-cmake-buildsystem development by creating an account on GitHub.

is something we might use in the superbuild on all platforms instead of having something Windows-specific. It supports both Python 2 and 3. 👍

---

<div class="post-metadata">

### Author: ![tj.corona](https://discourse.kitware.com/user_avatar/discourse.kitware.com/tj.corona/32/35_2.png) [@tj.corona](https://discourse.kitware.com/u/tj.corona)
#### Post date: [April 9, 2018, 1:16pm UTC](https://discourse.kitware.com/t/homebrew-on-macos/75/3 "2018-04-09T13:16:33Z")

</div>

Another option is to set the defaults for numpy and matplotlib to be the system ones. I think the system python2 on MacOS works with that configuration.

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [April 9, 2018, 1:34pm UTC](https://discourse.kitware.com/t/homebrew-on-macos/75/4 "2018-04-09T13:34:14Z")

</div>

[According to Apple](https://developer.apple.com/library/content/documentation/Security/Conceptual/System_Integrity_Protection_Guide/FileSystemProtections/FileSystemProtections.html#//apple_ref/doc/uid/TP40016462-CH2-DontLinkElementID_2), we should not use the system python. The very bottom of the linked page says:

> Developers using Perl, Python, Ruby, or any other scripting languages that ship with OS X, are encouraged to manage their own installations of the language and dependencies in /usr/local/. When distributing programs written with a scripting language, developers are encouraged to bundle the language runtime and any required components into a self-contained binary.

While we might be able to make it work in the build directory, it sounds like installing SMTK’s python modules system-wide would be impossible and perhaps even installing in `~/Library/` is discouraged.

---

<div class="post-metadata">

### Author: ![tj.corona](https://discourse.kitware.com/user_avatar/discourse.kitware.com/tj.corona/32/35_2.png) [@tj.corona](https://discourse.kitware.com/u/tj.corona)
#### Post date: [April 16, 2018, 12:57pm UTC](https://discourse.kitware.com/t/homebrew-on-macos/75/5 "2018-04-16T12:57:54Z")

</div>

Without input from Ben, I am reluctant to try and make the common superbuild build python on a mac. I have a sinking feeling that there is a long story behind the following two lines:

superbuild/projects/apple/python.cmake:

```auto
superbuild_add_project(python
  MUST_USE_SYSTEM)

```

---

<div class="post-metadata">

### Author: ![tj.corona](https://discourse.kitware.com/user_avatar/discourse.kitware.com/tj.corona/32/35_2.png) [@tj.corona](https://discourse.kitware.com/u/tj.corona)
#### Post date: [April 16, 2018, 12:59pm UTC](https://discourse.kitware.com/t/homebrew-on-macos/75/6 "2018-04-16T12:59:46Z")

</div>

Then again, we can’t freeze the build until we find out why system python is used on OS X. Kindly disregard my last comment!

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [April 16, 2018, 1:00pm UTC](https://discourse.kitware.com/t/homebrew-on-macos/75/7 "2018-04-16T13:00:04Z")

</div>

Over the weekend I did another brew update and see that they now offer `brew install python@2` which will probably work for now.
