diff --git a/brew-formulas.txt b/brew-formulas.txt new file mode 100644 index 0000000000..61e3d33e3a --- /dev/null +++ b/brew-formulas.txt @@ -0,0 +1,8 @@ +readline +sqlite +gdbm +pkg-config +gfortran +python +yuicompressor +node diff --git a/create-dev-env.sh b/create-dev-env.sh new file mode 100755 index 0000000000..a45fc0dba0 --- /dev/null +++ b/create-dev-env.sh @@ -0,0 +1,273 @@ +#!/bin/bash +set -e +trap "ouch" ERR + +ouch() { + printf '\E[31m' + + cat<>$LOG + output "Cloning askbot-devel" + if [[ -d "$BASE/askbot-devel" ]]; then + mv "$BASE/askbot-devel" "${BASE}/askbot-devel.bak.$$" + fi + git clone git@github.com:MITx/askbot-devel >>$LOG + output "Cloning data" + if [[ -d "$BASE/data" ]]; then + mv "$BASE/data" "${BASE}/data.bak.$$" + fi + hg clone ssh://hg-content@gp.mitx.mit.edu/data >>$LOG +} + +PROG=${0##*/} +BASE="$HOME/mitx_all" +PYTHON_DIR="$BASE/python" +RUBY_DIR="$BASE/ruby" +RUBY_VER="1.9.3" +NUMPY_VER="1.6.2" +SCIPY_VER="0.10.1" +BREW_FILE="$BASE/mitx/brew-formulas.txt" +LOG="/var/tmp/install.log" +APT_PKGS="curl git mercurial python-virtualenv build-essential python-dev gfortran liblapack-dev libfreetype6-dev libpng12-dev libxml2-dev libxslt-dev yui-compressor coffeescript" + +if [[ $EUID -eq 0 ]]; then + error "This script should not be run using sudo or as the root user" + usage + exit 1 +fi +ARGS=$(getopt "cvh" "$*") +if [[ $? != 0 ]]; then + usage + exit 1 +fi +eval set -- "$ARGS" +while true; do + case $1 in + -c) + compile=true + shift + ;; + -v) + set -x + verbose=true + shift + ;; + -h) + usage + exit 0 + ;; + --) + shift + break + ;; + esac +done + +cat< $HOME/.rvmrc +fi +mkdir -p $BASE +rm -f $LOG +case `uname -s` in + [Ll]inux) + command -v lsb_release &>/dev/null || { + error "Please install lsb-release." + exit 1 + } + distro=`lsb_release -cs` + case $distro in + lisa|natty|oneiric|precise) + output "Installing ubuntu requirements" + sudo apt-get -y update + sudo apt-get -y install $APT_PKGS + clone_repos + ;; + *) + error "Unsupported distribution - $distro" + exit 1 + ;; + esac + ;; + Darwin) + command -v brew &>/dev/null || { + output "Installing brew" + /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)" + } + command -v git &>/dev/null || { + output "Installing git" + brew install git >> $LOG + } + command -v hg &>/dev/null || { + output "Installaing mercurial" + brew install mercurial >> $LOG + } + + clone_repos + + output "Installing OSX requirements" + if [[ ! -r $BREW_FILE ]]; then + error "$BREW_FILE does not exist, needed to install brew deps" + exit 1 + fi + # brew errors if the package is already installed + for pkg in $(cat $BREW_FILE); do + grep $pkg <(brew list) &>/dev/null || { + output "Installing $pkg" + brew install $pkg >>$LOG + } + done + command -v pip &>/dev/null || { + output "Installing pip" + sudo easy_install pip >>$LOG + } + command -v virtualenv &>/dev/null || { + output "Installing virtualenv" + sudo pip install virtualenv virtualenvwrapper >> $LOG + } + command -v coffee &>/dev/null || { + output "Installing coffee script" + curl http://npmjs.org/install.sh | sh + npm install -g coffee-script + } + ;; + *) + error "Unsupported platform" + exit 1 + ;; +esac + +output "Installing rvm and ruby" +curl -sL get.rvm.io | bash -s stable +source $RUBY_DIR/scripts/rvm +rvm install $RUBY_VER +virtualenv "$PYTHON_DIR" +source $PYTHON_DIR/bin/activate +output "Installing gem bundler" +gem install bundler +output "Installing ruby packages" +# hack :( +cd $BASE/mitx || true +bundle install + +cd $BASE + +if [[ -n $compile ]]; then + output "Downloading numpy and scipy" + curl -sL -o numpy.tar.gz http://downloads.sourceforge.net/project/numpy/NumPy/${NUMPY_VER}/numpy-${NUMPY_VER}.tar.gz + curl -sL -o scipy.tar.gz http://downloads.sourceforge.net/project/scipy/scipy/${SCIPY_VER}/scipy-${SCIPY_VER}.tar.gz + tar xf numpy.tar.gz + tar xf scipy.tar.gz + rm -f numpy.tar.gz scipy.tar.gz + output "Compiling numpy" + cd "$BASE/numpy-${NUMPY_VER}" + python setup.py install >>$LOG 2>&1 + output "Compiling scipy" + cd "$BASE/scipy-${SCIPY_VER}" + python setup.py install >>$LOG 2>&1 + cd "$BASE" + rm -rf numpy-${NUMPY_VER} scipy-${SCIPY_VER} +fi + +output "Installing askbot requirements" +pip install -r askbot-devel/askbot_requirements.txt >>$LOG +pip install -r askbot-devel/askbot_requirements_dev.txt >>$LOG +output "Installing MITx requirements" +pip install -r mitx/pre-requirements.txt >> $LOG +pip install -r mitx/requirements.txt >>$LOG + +mkdir "$BASE/log" || true +mkdir "$BASE/db" || true + +cat< $HOME/.rvmrc + curl -sL get.rvm.io | bash -s stable + source ~/mitx_all/ruby/scripts/rvm + rvm install 1.9.3 + gem install bundler + cd ~/mitx_all/mitx + bundle install + +5) Install python libraries + + source ~/mitx_all/python/bin/activate + cd ~/mitx_all + pip install -r askbot-devel/askbot_requirements.txt + pip install -r askbot-devel/askbot_requirements_dev.txt + pip install -r mitx/pre-requirements.txt + pip install -r mitx/requirements.txt + +6) Create log and db dirs + + mkdir ~/mitx_all/log + mkdir ~/mitx_all/db + +7) Start the dev server + + To start using Django you will need + to activate the local Python and Ruby + environment: + + $ source ~/mitx_all/ruby/scripts/rvm + $ source ~/mitx_all/python/bin/activate + + To initialize and start a local instance of Django: + + $ cd ~/mitx_all/mitx + $ django-admin.py syncdb --settings=envs.dev --pythonpath=. + $ django-admin.py migrate --settings=envs.dev --pythonpath=. + $ django-admin.py runserver --settings=envs.dev --pythonpath=. + +