#!/bin/sh

# install brew
hash brew &> /dev/null
if [ $? -eq 1 ]; then
    echo 'Installing Homebrew ...'
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

# Ensure Homebrew formulae are updated
brew update

hash git &> /dev/null
if [ $? -eq 1 ]; then
    echo 'Installing Git ...'
    brew install git
fi

hash gcc &> /dev/null
if [ $? -eq 1 ]; then
    echo 'No gcc detected; Installing XCode Command Line Tools ...'
    xcode-select --install
fi

# Add science tap
brew tap homebrew/science

# Python tools and utilities
brew install python

# write export PATH=/usr/local/bin:$PATH in .profile or .bash_profile or .zshrc
# and check by `which python`

brew install gfortran  # required for scipy
brew install freetype  # required for matplotlib

# IPython
brew install zeromq
pip install jinja2
pip install tornado
pip install pyzmq
pip install ipython

# NumPy
pip install numpy

# SciPy
pip install scipy
# pip install git+git://github.com/scipy/scipy#egg=scipy-dev

# Matplotlib
pip install matplotlib
#pip install git+git://github.com/matplotlib/matplotlib.git

# Rest of the stack
pip install git+git://github.com/pydata/pandas.git
pip install git+git://github.com/scikit-learn/scikit-learn.git
pip install git+git://github.com/statsmodels/statsmodels.git

# optional: call ipython qith qtconsole is nice 
# call: ipython qtconsole

brew install sip
brew install pyqt