quickstart.sh 1.63 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
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
20
pip install -U pip setuptools
21
22
23
pip install -e .[testing]

# Install client dependencies
24
src/memopol/bin/install_client_deps.sh
25

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

35
36
37
38
39
# 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
40
memopol migrate
41
42

# Import sample data
Jamesie Pic's avatar
Jamesie Pic committed
43
memopol loaddata data_sample.json
44
45
46
47
48
49

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
50
echo "  memopol runserver"
51
52
53
54
55
56
57
58
59
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