quickstart.sh 1.62 KB
Newer Older
1 2 3 4 5 6 7
#!/bin/bash

#
# Quick-start script for new developers
# Usage: from repo root, `source bin/quickstart.sh`
#

8 9
set -x

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
REPOROOT=$(dirname $(dirname $0))

# Ensure we're at the root of the memopol repository
pushd $REPOROOT >/dev/null

# Create & activate python virtual environment
virtualenv memopol_env
source memopol_env/bin/activate

# Install python dependencies
pip install -e .[testing]

# Install client dependencies
bin/install_client_deps.sh

25 26 27 28 29 30 31 32 33
# Create pg user and database
if [ $(psql -c "select 'CNT=' || count(1) from pg_catalog.pg_user where usename='memopol';" -U postgres | grep CNT=1 | wc -l) -lt 1 ]; then
	psql -c "create user memopol with password 'memopol';" -U postgres
fi
psql -c "alter role memopol with createdb;" -U postgres
if [ $(psql -l -U postgres | egrep "^ memopol\W" | wc -l) -lt 1 ]; then
	psql -c "create database memopol with owner memopol;" -U postgres
fi

34 35 36 37 38 39 40 41
# Setup environment
export DJANGO_DEBUG=True
export DJANGO_SETTINGS_MODULE=memopol.settings

# Run django migration to create database
./manage.py migrate

# Import sample data
42
./manage.py loaddata memopol/fixtures/data_sample.json
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

echo
echo "You're all set!"
echo "To start the application run the following from the repository root ($REPOROOT):"
echo "  source memopol_env/bin/activate"
echo "  export DJANGO_DEBUG=True DJANGO_SETTINGS_MODULE=memopol.settings"
echo "  ./manage.py runserver"
echo
echo "If you make changes, don't forget to run tests using:"
echo "  flake8 . --exclude '*/migrations,docs,static' --ignore E128"
echo "  py.test memopol representatives_positions representatives_recommendations"
echo
echo "Happy hacking ;)"
echo

popd >/dev/null