macOS Sierra 10.12 開発環境構築 (クリーンインストール)

# Items to install

* Homebrew
* JDK
* Command Line Tools
* MySQL
* Git
* MeCab, NLTK
* Ruby, rbenv, rails
* Node.js
* pyenv, virtualenv, Django, Tensorflow
* AWS CLI
* CocoaPods



# Set system locale

<!---
-->

```

$ cat >> ~/.bash_profile << EOF
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
EOF

$ source ~/.bash_profile

```

# Install JDK

[Java SE Development Kit 8 Downloads](http://www.oracle.com/technetwork/java/javase/downloads/index.html)

```
$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
```





# Install Command Line Tools for Xcode
[Command Line Tools (macOS 10.12) for Xcode 8]
(https://developer.apple.com/downloads/)







# Install homebrew

```
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

$ brew doctor
Your system is ready to brew.

$ brew update
Already up-to-date.

$ brew -v
Homebrew 1.0.8
Homebrew/homebrew-core (git revision 74b2; last commit 2016-10-24)
```








# Install MySQL
```
$ brew install mysql
==> Installing mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.11.el_capitan.bottle.tar.gz
...
```




# Install Git

```
$ git --version
git version 2.8.4 (Apple Git-73)

$ brew install git
==> Downloading https://homebrew.bintray.com/bottles/git-2.10.1.sierra.bottle.tar.gz
...

$ echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

$ source ~/.bash_profile

$ brew unlink git && brew link git

$ git --version
git version 2.10.1
```




<!---
# Install OpenSSL

```
$ which openssl
/usr/bin/openssl

$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016

$ brew install openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.sierra.bottle.tar.gz

$ brew link --force openssl
Linking /usr/local/Cellar/openssl/1.0.2g... 1588 symlinks created

$ which openssl
/usr/local/bin/openssl
```
-->




# Install MeCab

```
$ brew install mecab mecab-ipadic xz

$ cd ~/Downloads && git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git

$ cd mecab-ipadic-neologd && ./bin/install-mecab-ipadic-neologd -n

$ echo `mecab-config --dicdir`"/mecab-ipadic-neologd"
/usr/local/lib/mecab/dic/mecab-ipadic-neologd
```







# Install Readline

```
$ brew install readline
==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.sierra.bottle.tar.gz
...
```









# Install Ruby, rbenv, and Rails

```
$ brew install rbenv ruby-build rbenv-gemset
==> Installing dependencies for rbenv: autoconf, pkg-config, ruby-build
==> Installing rbenv dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.sierra.bottle.4.tar.gz
...

$ rbenv -v
rbenv 1.0.0

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

$ source ~/.bash_profile

$ cat >> ~/.gemrc << EOF
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
EOF

$ cat >> ~/.railsrc << EOF
--skip-bundle
--skip-test-unit
EOF

$ rbenv install -l
...
2.2.5
...

$ rbenv install 2.2.5

$ rbenv global 2.2.5

$ ruby -v
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin16]

$ which ruby
/Users/*****/.rbenv/shims/ruby

$ gem update --system

$ gem install rails bundler rbenv-rehash

$ gem install --pre sass compass compass-recipes animation susy haml

$ rbenv rehash

```









# Install node.js

```
$ brew install nodebrew
==> Using the sandbox
==> Downloading https://github.com/hokaccha/nodebrew/archive/v0.9.6.tar.gz
==> Downloading from https://codeload.github.com/hokaccha/nodebrew/tar.gz/v0.9.6
######################################################################## 100.0%
==> /usr/local/Cellar/nodebrew/0.9.6/bin/nodebrew setup_dirs
...

$ mkdir -p ~/.nodebrew/src

$ echo ' export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile

$ source ~/.bash_profile

$ nodebrew install-binary stable
Fetching: https://nodejs.org/dist/v6.9.1/node-v6.9.1-darwin-x64.tar.gz
######################################################################## 100.0%
Installed successfully

$ nodebrew use stable
use v6.9.1

$ nodebrew ls
v6.9.1

current: v6.9.1

$ npm --version
3.10.8

```








# Install pyenv & virtualenv

```
$ python --version
Python 2.7.10

$ which python
/usr/bin/python

$ brew install pyenv
==> Downloading https://github.com/yyuu/pyenv/archive/v1.0.2.tar.gz
...

$ brew install homebrew/boneyard/pyenv-pip-rehash
==> Tapping homebrew/boneyard
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-boneyard'...
...

$ vi ~/.bash_profile
...
export PYENV_ROOT=${HOME}/.pyenv
if [ -d "${PYENV_ROOT}" ]; then
    export PATH=${PYENV_ROOT}/bin:$PATH
    eval "$(pyenv init -)"
fi

$ pyenv versions
* system (set by /Users/*****/.pyenv/version)

$ pyenv install --list
...
2.7.12
3.4.5
...

$ pyenv install 3.4.5

$ pyenv versions
* system (set by /Users/*****/.pyenv/version)
  3.4.5

$ pyenv global 3.4.5 && pyenv versions
  system
* 3.4.5 (set by /Users/*****/.pyenv/version)

$ pip install --upgrade pip

$ brew install pyenv-virtualenv pyenv-virtualenvwrapper

$ vi ~/.bash_profile
...
export PYENV_ROOT=${HOME}/.pyenv
if [ -d "${PYENV_ROOT}" ]; then
    export PATH=${PYENV_ROOT}/bin:$PATH
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
    export PYENV_VIRTUALENVWRAPPER_PREFER_PYVENV="true"
    pyenv virtualenvwrapper
fi


$ source ~/.bash_profile
```



# Install AWS CLI

```
$ brew install jq
$ pip install awscli boto boto3
```





# Install Django on virtualenv

```
$ mkvirtualenv django_app

(django_app)$ cat >> ./requirements.txt << EOF
... (write module names you want to install) ...
Django=1.9
... (write module names you want to install) ...
EOF

(django_app)$ pip install -r requirements.txt
Downloading/unpacking django (from -r pip-install.txt (line 1))
...

(django_app)$ source deactivate
```





# Install Tensorflow on virtualenv

```
$ mkvirtualenv --system-site-packages tensorflow

(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0-py3-none-any.whl

(tensorflow)$ pip3 install --upgrade $TF_BINARY_URL

(tensorflow)$ pip3 install matplotlib

(tensorflow)$ source deactivate
```






# Install gettext for i18n

```
$ brew install gettext
$ brew link gettext --force
```






# Install CocoaPods

```
$ gem install cocoapods

$ pod setup
```