Merge pull request #25 from edx/slater/new_mac_dev_script
Slater/new mac dev script
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -72,3 +72,4 @@ Giulio Gratta <giulio@giuliogratta.com>
|
||||
David Baumgold <david@davidbaumgold.com>
|
||||
Jason Bau <jbau@stanford.edu>
|
||||
Frances Botsford <frances@edx.org>
|
||||
Slater Victoroff <slater.r.victoroff@gmail.com>
|
||||
|
||||
@@ -8,8 +8,8 @@ Installation
|
||||
The installation process is a bit messy at the moment. Here's a high-level
|
||||
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
|
||||
of this up for you. If you're in a hurry, run that script. Otherwise, I suggest
|
||||
**TLDR:** There is a `scripts/create-dev-env.sh` that will attempt to set all of this up for you.
|
||||
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.
|
||||
|
||||
Directory Hierarchy
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
python-software-properties
|
||||
pkg-config
|
||||
gfortran
|
||||
libatlas-dev
|
||||
libblas-dev
|
||||
liblapack-dev
|
||||
liblapack3gf
|
||||
curl
|
||||
git
|
||||
python-virtualenv
|
||||
python-scipy
|
||||
python-numpy
|
||||
build-essential
|
||||
python-dev
|
||||
gfortran
|
||||
liblapack-dev
|
||||
libfreetype6-dev
|
||||
libpng12-dev
|
||||
libjpeg-dev
|
||||
@@ -14,6 +20,7 @@ libxml2-dev
|
||||
libxslt-dev
|
||||
yui-compressor
|
||||
graphviz
|
||||
libgraphviz-dev
|
||||
graphviz-dev
|
||||
mysql-server
|
||||
libmysqlclient-dev
|
||||
@@ -23,3 +30,7 @@ libreadline6-dev
|
||||
mongodb
|
||||
nodejs
|
||||
coffeescript
|
||||
mysql
|
||||
libmysqlclient-dev
|
||||
virtualenvwrapper
|
||||
libgeos-ruby1.8
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#Exit if any commands return a non-zero status
|
||||
set -e
|
||||
|
||||
# posix compliant sanity check
|
||||
@@ -27,10 +29,17 @@ EOL
|
||||
|
||||
}
|
||||
|
||||
#Setting error color to red before reset
|
||||
error() {
|
||||
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() {
|
||||
printf '\E[36m'; echo "$@"; printf '\E[0m'
|
||||
}
|
||||
@@ -51,7 +60,7 @@ EO
|
||||
|
||||
info() {
|
||||
cat<<EO
|
||||
MITx base dir : $BASE
|
||||
edX base dir : $BASE
|
||||
Python virtualenv dir : $PYTHON_DIR
|
||||
Ruby RVM dir : $RUBY_DIR
|
||||
Ruby ver : $RUBY_VER
|
||||
@@ -59,36 +68,31 @@ info() {
|
||||
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() {
|
||||
|
||||
change_git_push_defaults
|
||||
|
||||
cd "$BASE"
|
||||
|
||||
if [[ -d "$BASE/mitx/.git" ]]; then
|
||||
output "Pulling mitx"
|
||||
cd "$BASE/mitx"
|
||||
if [[ -d "$BASE/edx-platform/.git" ]]; then
|
||||
output "Pulling edx platform"
|
||||
cd "$BASE/edx-platform"
|
||||
git pull
|
||||
else
|
||||
output "Cloning mitx"
|
||||
if [[ -d "$BASE/mitx" ]]; then
|
||||
mv "$BASE/mitx" "${BASE}/mitx.bak.$$"
|
||||
output "Cloning edx platform"
|
||||
if [[ -d "$BASE/edx-platform" ]]; then
|
||||
output "Creating backup for existing edx platform"
|
||||
mv "$BASE/edx-platform" "${BASE}/edx-platform.bak.$$"
|
||||
fi
|
||||
git clone git@github.com:MITx/mitx.git
|
||||
fi
|
||||
|
||||
# By default, dev environments start with a copy of 6.002x
|
||||
cd "$BASE"
|
||||
mkdir -p "$BASE/data"
|
||||
REPO="content-mit-6002x"
|
||||
if [[ -d "$BASE/data/$REPO/.git" ]]; then
|
||||
output "Pulling $REPO"
|
||||
cd "$BASE/data/$REPO"
|
||||
git pull
|
||||
else
|
||||
output "Cloning $REPO"
|
||||
if [[ -d "$BASE/data/$REPO" ]]; then
|
||||
mv "$BASE/data/$REPO" "${BASE}/data/$REPO.bak.$$"
|
||||
fi
|
||||
cd "$BASE/data"
|
||||
git clone git@github.com:MITx/$REPO
|
||||
git clone https://github.com/edx/edx-platform.git
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -98,7 +102,7 @@ clone_repos() {
|
||||
PROG=${0##*/}
|
||||
|
||||
# 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
|
||||
# unless you've already got one set up with virtualenvwrapper.
|
||||
@@ -161,7 +165,7 @@ done
|
||||
|
||||
cat<<EO
|
||||
|
||||
This script will setup a local MITx environment, this
|
||||
This script will setup a local edX environment, this
|
||||
includes
|
||||
|
||||
* Django
|
||||
@@ -202,9 +206,31 @@ case `uname -s` in
|
||||
|
||||
distro=`lsb_release -cs`
|
||||
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
|
||||
;;
|
||||
;;
|
||||
|
||||
*)
|
||||
error "Unsupported distribution - $distro"
|
||||
exit 1
|
||||
@@ -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
|
||||
;;
|
||||
esac
|
||||
@@ -251,11 +277,18 @@ esac
|
||||
|
||||
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
|
||||
|
||||
bash $BASE/mitx/install-system-req.sh
|
||||
|
||||
output "Installing RVM, Ruby, and required gems"
|
||||
|
||||
# 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
|
||||
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
|
||||
# with the environment and set everything up properly. The RVM install
|
||||
@@ -294,8 +342,8 @@ case `uname -s` in
|
||||
esac
|
||||
|
||||
# Let the repo override the version of Ruby to install
|
||||
if [[ -r $BASE/mitx/.ruby-version ]]; then
|
||||
RUBY_VER=`cat $BASE/mitx/.ruby-version`
|
||||
if [[ -r $BASE/edx-platform/.ruby-version ]]; then
|
||||
RUBY_VER=`cat $BASE/edx-platform/.ruby-version`
|
||||
fi
|
||||
|
||||
# Current stable version of RVM (1.19.0) requires the following to build Ruby:
|
||||
@@ -311,14 +359,15 @@ fi
|
||||
# any required libs are missing.
|
||||
LESS="-E" rvm install $RUBY_VER --with-readline
|
||||
|
||||
# Create the "mitx" gemset
|
||||
rvm use "$RUBY_VER@mitx" --create
|
||||
# Create the "edx" gemset
|
||||
rvm use "$RUBY_VER@edx-platform" --create
|
||||
rvm rubygems latest
|
||||
|
||||
output "Installing gem bundler"
|
||||
gem install bundler
|
||||
|
||||
output "Installing ruby packages"
|
||||
bundle install --gemfile $BASE/mitx/Gemfile
|
||||
bundle install --gemfile $BASE/edx-platform/Gemfile
|
||||
|
||||
|
||||
# Install Python virtualenv
|
||||
@@ -338,20 +387,33 @@ export WORKON_HOME=$PYTHON_DIR
|
||||
|
||||
# Load in the mkvirtualenv function if needed
|
||||
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
|
||||
|
||||
# Create MITx virtualenv and link it to repo
|
||||
# Create edX virtualenv and link it to repo
|
||||
# virtualenvwrapper automatically sources the activation script
|
||||
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"
|
||||
return 1
|
||||
}
|
||||
else
|
||||
# default behavior for virtualenv>1.7 is
|
||||
# --no-site-packages
|
||||
mkvirtualenv -a "$BASE/mitx" mitx || {
|
||||
mkvirtualenv -a "$HOME/.virtualenvs" edx-platform || {
|
||||
error "mkvirtualenv exited with a non-zero error"
|
||||
return 1
|
||||
}
|
||||
@@ -380,10 +442,30 @@ if [[ -n $compile ]]; then
|
||||
rm -rf numpy-${NUMPY_VER} scipy-${SCIPY_VER}
|
||||
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
|
||||
Darwin)
|
||||
# on mac os x get the latest distribute and pip
|
||||
curl http://python-distribute.org/distribute_setup.py | python
|
||||
pip install -U pip
|
||||
# need latest pytz before compiling numpy and scipy
|
||||
pip install -U pytz
|
||||
@@ -395,18 +477,29 @@ case `uname -s` in
|
||||
;;
|
||||
esac
|
||||
|
||||
output "Installing MITx pre-requirements"
|
||||
pip install -r $BASE/mitx/pre-requirements.txt
|
||||
output "Installing edX pre-requirements"
|
||||
pip install -r $BASE/edx-platform/requirements/edx/pre.txt
|
||||
|
||||
output "Installing MITx requirements"
|
||||
# Need to be in the mitx dir to get the paths to local modules right
|
||||
cd $BASE/mitx
|
||||
pip install -r requirements.txt
|
||||
output "Installing edX requirements"
|
||||
# Install prereqs
|
||||
cd $BASE/edx-platform
|
||||
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/db" || true
|
||||
mkdir "$BASE/data" || true
|
||||
|
||||
|
||||
rake django-admin[syncdb]
|
||||
rake django-admin[migrate]
|
||||
rake django-admin[update-templates]
|
||||
# Configure Git
|
||||
|
||||
output "Fixing your git default settings"
|
||||
|
||||
@@ -16,10 +16,11 @@ output() {
|
||||
|
||||
### START
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
BREW_FILE=$DIR/"brew-formulas.txt"
|
||||
APT_REPOS_FILE=$DIR/"apt-repos.txt"
|
||||
APT_PKGS_FILE=$DIR/"apt-packages.txt"
|
||||
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
REQUIREMENTS_DIR="$SELF_DIR/../requirements/system"
|
||||
BREW_FILE=$REQUIREMENTS_DIR/"mac_os_x/brew-formulas.txt"
|
||||
APT_REPOS_FILE=$REQUIREMENTS_DIR/"ubuntu/apt-repos.txt"
|
||||
APT_PKGS_FILE=$REQUIREMENTS_DIR/"ubuntu/apt-packages.txt"
|
||||
|
||||
case `uname -s` in
|
||||
[Ll]inux)
|
||||
@@ -30,8 +31,9 @@ case `uname -s` in
|
||||
|
||||
distro=`lsb_release -cs`
|
||||
case $distro in
|
||||
maya|lisa|natty|oneiric|precise|quantal)
|
||||
output "Installing Ubuntu requirements"
|
||||
#Tries to install the same
|
||||
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
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
@@ -39,7 +41,10 @@ case `uname -s` in
|
||||
# add repositories
|
||||
cat $APT_REPOS_FILE | xargs -n 1 sudo add-apt-repository -y
|
||||
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
|
||||
cat $APT_PKGS_FILE | xargs sudo apt-get -y install
|
||||
;;
|
||||
@@ -70,10 +75,13 @@ EO
|
||||
|
||||
output "Installing OSX requirements"
|
||||
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
|
||||
fi
|
||||
|
||||
# for some reason openssl likes to be installed by itself first
|
||||
brew install openssl
|
||||
|
||||
# brew errors if the package is already installed
|
||||
for pkg in $(cat $BREW_FILE); do
|
||||
grep $pkg <(brew list) &>/dev/null || {
|
||||
|
||||
Reference in New Issue
Block a user