-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (52 loc) · 1.99 KB
/
Makefile
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
VENV ?= $(CURDIR)/../venv
SETTINGS ?= main.settings.local
MANAGER = $(CURDIR)/simple/manage.py
REQUIREMENTS = $(CURDIR)/requirements.txt
all: $(VENV)
$(VENV)/bin/python $(MANAGER) $(ARGS) --settings=$(SETTINGS)
.PHONY: help
# target: help - Display callable targets
help:
@egrep "^# target:" [Mm]akefile | sed -e 's/^# target: //g'
.PHONY: clean
# target: clean - Clean temporary files
clean:
@find $(CURDIR) -name "*.py[co]" -delete
@find $(CURDIR) -name "*.orig" -delete
@find $(CURDIR) -name "*.deb" -delete
@rm -rf build
$(VENV): $(REQUIREMENTS)
[ -d $(VENV) ] || virtualenv --no-site-packages $(VENV)
$(VENV)/bin/pip install -M -r $(REQUIREMENTS) --allow-external mysql-connector-python --allow-unverified mysql-connector-python
.PHONY: run
# target: run - Run Django development server
run: $(VENV)
$(VENV)/bin/python $(MANAGER) runserver_plus 0.0.0.0:8000 --settings=$(SETTINGS) || $(VENV)/bin/python $(MANAGER) runserver 0.0.0.0:8000 --settings=$(SETTINGS)
.PHONY: db
# target: db - Prepare database
db: $(VENV)
$(VENV)/bin/python $(MANAGER) syncdb --settings=$(SETTINGS) --noinput || echo 'sync failed'
$(VENV)/bin/python $(MANAGER) migrate --settings=$(SETTINGS) --noinput
.PHONY: shell
# target: shell - Run project shell
shell: $(VENV)
$(VENV)/bin/python $(MANAGER) shell_plus --settings=$(SETTINGS) || $(VENV)/bin/python $(MANAGER) shell --settings=$(SETTINGS)
.PHONY: static
# target: static - Compile project static
static: $(VENV)
@mkdir -p $(CURDIR)/static
$(VENV)/bin/python $(MANAGER) collectstatic --settings=$(SETTINGS) --noinput -c
.PHONY: lint
# target: lint - Code audit
lint: $(VENV)
@rm -rf pep8.pylama pylint.pylama
$(VENV)/bin/pip install pylama
$(VENV)/bin/pip install pylama_pylint
$(VENV)/bin/pylama . -r pep8.pylama -l pep257,pep8,pyflakes,mccabe || echo
$(VENV)/bin/pylama . -r pylint.pylama -l pylint -f pylint || echo
.PHONY: test t
# target: test - Run project's tests
TEST ?=
test: $(VENV)
$(VENV)/bin/python $(MANAGER) test $(TEST) --settings=main.settings.test
t: test