Commit 04842087 by Slater-Victoroff

Merge pull request #25 from edx/slater/new_mac_dev_script

Slater/new mac dev script
parents 4a997842 57e43770
...@@ -72,3 +72,4 @@ Giulio Gratta <giulio@giuliogratta.com> ...@@ -72,3 +72,4 @@ Giulio Gratta <giulio@giuliogratta.com>
David Baumgold <david@davidbaumgold.com> David Baumgold <david@davidbaumgold.com>
Jason Bau <jbau@stanford.edu> Jason Bau <jbau@stanford.edu>
Frances Botsford <frances@edx.org> Frances Botsford <frances@edx.org>
Slater Victoroff <slater.r.victoroff@gmail.com>
...@@ -8,8 +8,8 @@ Installation ...@@ -8,8 +8,8 @@ Installation
The installation process is a bit messy at the moment. Here's a high-level The installation process is a bit messy at the moment. Here's a high-level
overview of what you should do to get started. overview of what you should do to get started.
**TLDR:** There is a `scripts/create-dev-env.sh` script that will attempt to set all **TLDR:** There is a `scripts/create-dev-env.sh` that will attempt to set all of this up for you.
of this up for you. If you're in a hurry, run that script. Otherwise, I suggest If you're in a hurry, run that script. Otherwise, I suggest
that you understand what the script is doing, and why, by reading this document. that you understand what the script is doing, and why, by reading this document.
Directory Hierarchy Directory Hierarchy
......
python-software-properties python-software-properties
pkg-config pkg-config
gfortran
libatlas-dev
libblas-dev
liblapack-dev
liblapack3gf
curl curl
git git
python-virtualenv python-virtualenv
python-scipy
python-numpy
build-essential build-essential
python-dev python-dev
gfortran gfortran
liblapack-dev
libfreetype6-dev libfreetype6-dev
libpng12-dev libpng12-dev
libjpeg-dev libjpeg-dev
...@@ -14,6 +20,7 @@ libxml2-dev ...@@ -14,6 +20,7 @@ libxml2-dev
libxslt-dev libxslt-dev
yui-compressor yui-compressor
graphviz graphviz
libgraphviz-dev
graphviz-dev graphviz-dev
mysql-server mysql-server
libmysqlclient-dev libmysqlclient-dev
...@@ -23,3 +30,7 @@ libreadline6-dev ...@@ -23,3 +30,7 @@ libreadline6-dev
mongodb mongodb
nodejs nodejs
coffeescript coffeescript
mysql
libmysqlclient-dev
virtualenvwrapper
libgeos-ruby1.8
#!/usr/bin/env bash #!/usr/bin/env bash
#Exit if any commands return a non-zero status
set -e set -e
# posix compliant sanity check # posix compliant sanity check
...@@ -27,10 +29,17 @@ EOL ...@@ -27,10 +29,17 @@ EOL
} }
#Setting error color to red before reset
error() { error() {
printf '\E[31m'; echo "$@"; printf '\E[0m' printf '\E[31m'; echo "$@"; printf '\E[0m'
} }
#Setting warning color to magenta before reset
warning() {
printf '\E[35m'; echo "$@"; printf '\E[0m'
}
#Setting output color to cyan before reset
output() { output() {
printf '\E[36m'; echo "$@"; printf '\E[0m' printf '\E[36m'; echo "$@"; printf '\E[0m'
} }
...@@ -51,7 +60,7 @@ EO ...@@ -51,7 +60,7 @@ EO
info() { info() {
cat<<EO cat<<EO
MITx base dir : $BASE edX base dir : $BASE
Python virtualenv dir : $PYTHON_DIR Python virtualenv dir : $PYTHON_DIR
Ruby RVM dir : $RUBY_DIR Ruby RVM dir : $RUBY_DIR
Ruby ver : $RUBY_VER Ruby ver : $RUBY_VER
...@@ -59,36 +68,31 @@ info() { ...@@ -59,36 +68,31 @@ info() {
EO EO
} }
change_git_push_defaults() {
#Set git push defaults to upstream rather than master
output "Changing git defaults"
git config --global push.default upstream
}
clone_repos() { clone_repos() {
cd "$BASE"
if [[ -d "$BASE/mitx/.git" ]]; then change_git_push_defaults
output "Pulling mitx"
cd "$BASE/mitx"
git pull
else
output "Cloning mitx"
if [[ -d "$BASE/mitx" ]]; then
mv "$BASE/mitx" "${BASE}/mitx.bak.$$"
fi
git clone git@github.com:MITx/mitx.git
fi
# By default, dev environments start with a copy of 6.002x
cd "$BASE" cd "$BASE"
mkdir -p "$BASE/data"
REPO="content-mit-6002x" if [[ -d "$BASE/edx-platform/.git" ]]; then
if [[ -d "$BASE/data/$REPO/.git" ]]; then output "Pulling edx platform"
output "Pulling $REPO" cd "$BASE/edx-platform"
cd "$BASE/data/$REPO"
git pull git pull
else else
output "Cloning $REPO" output "Cloning edx platform"
if [[ -d "$BASE/data/$REPO" ]]; then if [[ -d "$BASE/edx-platform" ]]; then
mv "$BASE/data/$REPO" "${BASE}/data/$REPO.bak.$$" output "Creating backup for existing edx platform"
mv "$BASE/edx-platform" "${BASE}/edx-platform.bak.$$"
fi fi
cd "$BASE/data" git clone https://github.com/edx/edx-platform.git
git clone git@github.com:MITx/$REPO
fi fi
} }
...@@ -98,7 +102,7 @@ clone_repos() { ...@@ -98,7 +102,7 @@ clone_repos() {
PROG=${0##*/} PROG=${0##*/}
# Adjust this to wherever you'd like to place the codebase # Adjust this to wherever you'd like to place the codebase
BASE="${PROJECT_HOME:-$HOME}/mitx_all" BASE="${PROJECT_HOME:-$HOME}/edx_all"
# Use a sensible default (~/.virtualenvs) for your Python virtualenvs # Use a sensible default (~/.virtualenvs) for your Python virtualenvs
# unless you've already got one set up with virtualenvwrapper. # unless you've already got one set up with virtualenvwrapper.
...@@ -161,7 +165,7 @@ done ...@@ -161,7 +165,7 @@ done
cat<<EO cat<<EO
This script will setup a local MITx environment, this This script will setup a local edX environment, this
includes includes
* Django * Django
...@@ -202,9 +206,31 @@ case `uname -s` in ...@@ -202,9 +206,31 @@ case `uname -s` in
distro=`lsb_release -cs` distro=`lsb_release -cs`
case $distro in case $distro in
maya|lisa|natty|oneiric|precise|quantal) wheezy|jessie|maya|olivia|nadia|precise|quantal)
warning "Debian support is not fully debugged. Assuming you have standard
development packages already working like scipy rvm, the
installation should go fine, but this is still a work in progress.
Please report issues you have and let us know if you are able to figure
out any workarounds or solutions
Press return to continue or control-C to abort"
read dummy
sudo apt-get install git ;;
squeeze|lisa|katya|oneiric|natty|raring)
warning "It seems like you're using $distro which has been deprecated.
While we don't technically support this release, the install
script will probably still work.
Raring requires an install of rvm to work correctly as the raring
package manager does not yet include a package for rvm
Press return to continue or control-C to abort"
read dummy
sudo apt-get install git sudo apt-get install git
;; ;;
*) *)
error "Unsupported distribution - $distro" error "Unsupported distribution - $distro"
exit 1 exit 1
...@@ -241,7 +267,7 @@ EO ...@@ -241,7 +267,7 @@ EO
;; ;;
*) *)
error "Unsupported platform" error "Unsupported platform. Try switching to either Mac or a Debian-based linux distribution (Ubuntu, Debian, or Mint)"
exit 1 exit 1
;; ;;
esac esac
...@@ -251,11 +277,18 @@ esac ...@@ -251,11 +277,18 @@ esac
clone_repos clone_repos
# Sanity check to make sure the repo layout hasn't changed
if [[ -d $BASE/edx-platform/scripts ]]; then
output "Installing system-level dependencies"
bash $BASE/edx-platform/scripts/install-system-req.sh
else
error "It appears that our directory structure has changed and somebody failed to update this script.
raise an issue on Github and someone should fix it."
exit 1
fi
# Install system-level dependencies # Install system-level dependencies
bash $BASE/mitx/install-system-req.sh
output "Installing RVM, Ruby, and required gems" output "Installing RVM, Ruby, and required gems"
# If we're not installing RVM in the default location, then we'll do some # If we're not installing RVM in the default location, then we'll do some
...@@ -271,7 +304,22 @@ if [ "$HOME/.rvm" != $RUBY_DIR ]; then ...@@ -271,7 +304,22 @@ if [ "$HOME/.rvm" != $RUBY_DIR ]; then
fi fi
fi fi
curl -sL get.rvm.io | bash -s -- --version 1.15.7 # rvm has issues in debian family, this is taken from stack overflow
case `uname -s` in
Darwin)
curl -sL get.rvm.io | bash -s -- --version 1.15.7
;;
squeeze|wheezy|jessie|maya|lisa|olivia|nadia|natty|oneiric|precise|quantal|raring)
warning "Setting up rvm on linux. This is a known pain point. If the script fails here
refer to the following stack overflow question:
http://stackoverflow.com/questions/9056008/installed-ruby-1-9-3-with-rvm-but-command-line-doesnt-show-ruby-v/9056395#9056395"
sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh
curl -sL https://get.rvm.io | bash -s stable --ruby --autolibs=enable --autodotfiles
;;
esac
# Ensure we have RVM available as a shell function so that it can mess # Ensure we have RVM available as a shell function so that it can mess
# with the environment and set everything up properly. The RVM install # with the environment and set everything up properly. The RVM install
...@@ -294,8 +342,8 @@ case `uname -s` in ...@@ -294,8 +342,8 @@ case `uname -s` in
esac esac
# Let the repo override the version of Ruby to install # Let the repo override the version of Ruby to install
if [[ -r $BASE/mitx/.ruby-version ]]; then if [[ -r $BASE/edx-platform/.ruby-version ]]; then
RUBY_VER=`cat $BASE/mitx/.ruby-version` RUBY_VER=`cat $BASE/edx-platform/.ruby-version`
fi fi
# Current stable version of RVM (1.19.0) requires the following to build Ruby: # Current stable version of RVM (1.19.0) requires the following to build Ruby:
...@@ -311,14 +359,15 @@ fi ...@@ -311,14 +359,15 @@ fi
# any required libs are missing. # any required libs are missing.
LESS="-E" rvm install $RUBY_VER --with-readline LESS="-E" rvm install $RUBY_VER --with-readline
# Create the "mitx" gemset # Create the "edx" gemset
rvm use "$RUBY_VER@mitx" --create rvm use "$RUBY_VER@edx-platform" --create
rvm rubygems latest
output "Installing gem bundler" output "Installing gem bundler"
gem install bundler gem install bundler
output "Installing ruby packages" output "Installing ruby packages"
bundle install --gemfile $BASE/mitx/Gemfile bundle install --gemfile $BASE/edx-platform/Gemfile
# Install Python virtualenv # Install Python virtualenv
...@@ -338,20 +387,33 @@ export WORKON_HOME=$PYTHON_DIR ...@@ -338,20 +387,33 @@ export WORKON_HOME=$PYTHON_DIR
# Load in the mkvirtualenv function if needed # Load in the mkvirtualenv function if needed
if [[ `type -t mkvirtualenv` != "function" ]]; then if [[ `type -t mkvirtualenv` != "function" ]]; then
source `which virtualenvwrapper.sh` case `uname -s` in
Darwin)
source `which virtualenvwrapper.sh`
;;
squeeze|wheezy|jessie|maya|lisa|olivia|nadia|natty|oneiric|precise|quantal|raring)
if [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
source /etc/bash_completion.d/virtualenvwrapper
else
error "Could not find virtualenvwrapper"
exit 1
fi
;;
esac
fi fi
# Create MITx virtualenv and link it to repo # Create edX virtualenv and link it to repo
# virtualenvwrapper automatically sources the activation script # virtualenvwrapper automatically sources the activation script
if [[ $systempkgs ]]; then if [[ $systempkgs ]]; then
mkvirtualenv -a "$BASE/mitx" --system-site-packages mitx || { mkvirtualenv -a "$HOME/.virtualenvs" --system-site-packages edx-platform || {
error "mkvirtualenv exited with a non-zero error" error "mkvirtualenv exited with a non-zero error"
return 1 return 1
} }
else else
# default behavior for virtualenv>1.7 is # default behavior for virtualenv>1.7 is
# --no-site-packages # --no-site-packages
mkvirtualenv -a "$BASE/mitx" mitx || { mkvirtualenv -a "$HOME/.virtualenvs" edx-platform || {
error "mkvirtualenv exited with a non-zero error" error "mkvirtualenv exited with a non-zero error"
return 1 return 1
} }
...@@ -380,10 +442,30 @@ if [[ -n $compile ]]; then ...@@ -380,10 +442,30 @@ if [[ -n $compile ]]; then
rm -rf numpy-${NUMPY_VER} scipy-${SCIPY_VER} rm -rf numpy-${NUMPY_VER} scipy-${SCIPY_VER}
fi fi
# building correct version of distribute from source
DISTRIBUTE_VER="0.6.28"
output "Building Distribute"
SITE_PACKAGES="$HOME/.virtualenvs/edx-platform/lib/python2.7/site-packages"
cd "$SITE_PACKAGES"
curl -O http://pypi.python.org/packages/source/d/distribute/distribute-${DISTRIBUTE_VER}.tar.gz
tar -xzvf distribute-${DISTRIBUTE_VER}.tar.gz
cd distribute-${DISTRIBUTE_VER}
python setup.py install
cd ..
rm distribute-${DISTRIBUTE_VER}.tar.gz
DISTRIBUTE_VERSION=`pip freeze | grep distribute`
if [[ "$DISTRIBUTE_VERSION" == "distribute==0.6.28" ]]; then
output "Distribute successfully installed"
else
error "Distribute failed to build correctly. This script requires a working version of Distribute 0.6.28 in your virtualenv's python installation"
exit 1
fi
case `uname -s` in case `uname -s` in
Darwin) Darwin)
# on mac os x get the latest distribute and pip # on mac os x get the latest distribute and pip
curl http://python-distribute.org/distribute_setup.py | python
pip install -U pip pip install -U pip
# need latest pytz before compiling numpy and scipy # need latest pytz before compiling numpy and scipy
pip install -U pytz pip install -U pytz
...@@ -395,18 +477,29 @@ case `uname -s` in ...@@ -395,18 +477,29 @@ case `uname -s` in
;; ;;
esac esac
output "Installing MITx pre-requirements" output "Installing edX pre-requirements"
pip install -r $BASE/mitx/pre-requirements.txt pip install -r $BASE/edx-platform/requirements/edx/pre.txt
output "Installing MITx requirements" output "Installing edX requirements"
# Need to be in the mitx dir to get the paths to local modules right # Install prereqs
cd $BASE/mitx cd $BASE/edx-platform
pip install -r requirements.txt rvm use $RUBY_VER
rake install_prereqs
# Final dependecy
output "Finishing Touches"
cd $BASE
pip install argcomplete
cd $BASE/edx-platform
bundle install
mkdir "$BASE/log" || true mkdir "$BASE/log" || true
mkdir "$BASE/db" || true mkdir "$BASE/db" || true
mkdir "$BASE/data" || true
rake django-admin[syncdb]
rake django-admin[migrate]
rake django-admin[update-templates]
# Configure Git # Configure Git
output "Fixing your git default settings" output "Fixing your git default settings"
......
...@@ -16,10 +16,11 @@ output() { ...@@ -16,10 +16,11 @@ output() {
### START ### START
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BREW_FILE=$DIR/"brew-formulas.txt" REQUIREMENTS_DIR="$SELF_DIR/../requirements/system"
APT_REPOS_FILE=$DIR/"apt-repos.txt" BREW_FILE=$REQUIREMENTS_DIR/"mac_os_x/brew-formulas.txt"
APT_PKGS_FILE=$DIR/"apt-packages.txt" APT_REPOS_FILE=$REQUIREMENTS_DIR/"ubuntu/apt-repos.txt"
APT_PKGS_FILE=$REQUIREMENTS_DIR/"ubuntu/apt-packages.txt"
case `uname -s` in case `uname -s` in
[Ll]inux) [Ll]inux)
...@@ -30,8 +31,9 @@ case `uname -s` in ...@@ -30,8 +31,9 @@ case `uname -s` in
distro=`lsb_release -cs` distro=`lsb_release -cs`
case $distro in case $distro in
maya|lisa|natty|oneiric|precise|quantal) #Tries to install the same
output "Installing Ubuntu requirements" squeeze|wheezy|jessie|maya|lisa|olivia|nadia|natty|oneiric|precise|quantal|raring)
output "Installing Debian family requirements"
# DEBIAN_FRONTEND=noninteractive is required for silent mysql-server installation # DEBIAN_FRONTEND=noninteractive is required for silent mysql-server installation
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
...@@ -39,7 +41,10 @@ case `uname -s` in ...@@ -39,7 +41,10 @@ case `uname -s` in
# add repositories # add repositories
cat $APT_REPOS_FILE | xargs -n 1 sudo add-apt-repository -y cat $APT_REPOS_FILE | xargs -n 1 sudo add-apt-repository -y
sudo apt-get -y update sudo apt-get -y update
sudo apt-get -y install gfortran
sudo apt-get -y install graphviz libgraphviz-dev graphviz-dev
sudo apt-get -y install libatlas-dev libblas-dev
sudo apt-get -y install ruby-rvm
# install packages listed in APT_PKGS_FILE # install packages listed in APT_PKGS_FILE
cat $APT_PKGS_FILE | xargs sudo apt-get -y install cat $APT_PKGS_FILE | xargs sudo apt-get -y install
;; ;;
...@@ -70,10 +75,13 @@ EO ...@@ -70,10 +75,13 @@ EO
output "Installing OSX requirements" output "Installing OSX requirements"
if [[ ! -r $BREW_FILE ]]; then if [[ ! -r $BREW_FILE ]]; then
error "$BREW_FILE does not exist, needed to install brew" error "$BREW_FILE does not exist, please include the brew formulas file in the requirements/system/mac_os_x directory"
exit 1 exit 1
fi fi
# for some reason openssl likes to be installed by itself first
brew install openssl
# brew errors if the package is already installed # brew errors if the package is already installed
for pkg in $(cat $BREW_FILE); do for pkg in $(cat $BREW_FILE); do
grep $pkg <(brew list) &>/dev/null || { grep $pkg <(brew list) &>/dev/null || {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment