~mgedmin/ubuntu.lt/socialauth

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Default target

TESTS = socialplugin_articles
COVERAGE_INCLUDES = --include=apps/social*,project/*


.PHONY: all

all: develop


###############
# Development #
###############

.PHONY: develop run tags todo test flake8 syncdb clean realclean

develop: bootstrap.py \
         bin/buildout \
         bin/django \
         var/development.db \
         docs/build/html \
         var/htdocs/static

run:
	bin/django runserver

tags:
	bin/ctags -v

todo:
	@egrep -n 'FIXME|TODO' $$(find apps -iname '*.py' ; \
	                          find project -iname '*.py')

test:
	bin/django test socialplugin_articles

coverage:
	bin/coverage run bin/django test $(TESTS)
	bin/coverage html $(COVERAGE_INCLUDES)
	bin/coverage report $(COVERAGE_INCLUDES)
	@echo "Also try xdg-open htmlcov/index.html"

flake8:
	@bin/flake8 \
	    apps/avatarplugin-email/avatarplugin_email/ \
	    apps/avatars/avatars/ \
	    apps/wora/wora/ \
	    project/

syncdb:
	test ! -f bin/django.wsgi
	if [ -f var/development.db ] ; then rm var/development.db ; fi
	bin/django syncdb --all --noinput
	bin/django migrate --fake
	bin/django loaddata initial_data.json

# circo dot fdp neato nop nop1 nop2 twopi
graph:
	bin/django graph_models \
	    --group-models \
	    --all-applications \
	    -o var/graph.png
	xdg-open var/graph.png

bin/django: bin/buildout buildout.cfg development.cfg apps/*/setup.py
	test ! -f bin/django.wsgi
	bin/buildout -c development.cfg -N
	touch -c $@

var/development.db:
	test ! -f bin/django.wsgi
	bin/django syncdb --all --noinput
	bin/django migrate --fake
	bin/django loaddata initial_data.json

docs/build/html: $(find docs -type f -not -wholename 'docs/build/*')
	cd docs ; make html

clean:


realclean: clean
	bzr clean-tree --ignored --unknown


##############
# Deployment #
##############

.PHONY: deploy

deploy: bootstrap.py \
	bin/buildout \
	bin/django.wsgi \
	project/production.py \
	var/production.db \
	var/htdocs/static

bin/django.wsgi: bin/buildout buildout.cfg apps/*/setup.py etc/*.in
	test ! -f var/development.db
	bin/buildout -N
	touch -c $@

project/production.py:
	@echo
	@echo "project/production.py settings file is missing."
	@echo "Create this file and run make deploy again."
	@echo
	@echo "Here is example, how to prepare MySQL database:"
	@echo
	@echo "    CREATE USER '<user>'@'localhost' IDENTIFIED BY '<password>';"
	@echo "    GRANT ALL ON *.* TO '<user>'@'localhost';"
	@echo "    CREATE DATABASE <dbname> CHARACTER SET utf8;"
	@echo
	@echo "Use generated sample file: etc/my.cnf and specify "
	@echo "database connection credentials. You can use this file,"
	@echo "to connect to database:"
	@echo
	@echo "    mysql --defaults-extra-file=etc/my.cnf"
	@echo
	@echo "Use generated sample file: etc/production.py and "
	@echo "adjust your production server settings:"
	@echo
	@echo "    cp etc/production.py project/production.py"
	@echo "    vi project/production.py"
	@echo
	@exit 1

var/production.db:
	test ! -f var/development.db
	bin/django syncdb --all --noinput
	bin/django migrate --fake
	bin/django loaddata initial_data.json
	touch -c $@


###########
# General #
###########

bootstrap.py:
	mkdir -p eggs downloads
	wget http://www.python-distribute.org/bootstrap.py

bin/buildout:
	python bootstrap.py

var/htdocs/static:
	bin/django build_static --noinput