quickstart.sh 1.69 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

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

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
18
pip install -U pip setuptools
19
20
21
pip install -e .[testing]

# Install client dependencies
22
src/memopol/bin/install_client_deps.sh
23

24
25
26
27
28
29
30
31
32
# 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

33
34
35
36
37
# Setup environment
export DJANGO_DEBUG=True
export DJANGO_SETTINGS_MODULE=memopol.settings

# Run django migration to create database
Jamesie Pic's avatar
Jamesie Pic committed
38
memopol migrate
39
40

# Import sample data
Jamesie Pic's avatar
Jamesie Pic committed
41
memopol loaddata data_sample.json
42
memopol refresh_scores
43

44
45
46
# Build index for Whoosh
memopol rebuild_index

47
48
49
50
51
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"
Jamesie Pic's avatar
Jamesie Pic committed
52
echo "  memopol runserver"
53
54
55
56
57
58
59
60
61
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