forked from rbarrois/djadmin_export
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (83 loc) · 2.53 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
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
PACKAGE=djadmin_export
TESTS_DIR=tests
DOC_DIR=docs
# Use current python binary instead of system default.
COVERAGE = python $(shell which coverage)
FLAKE8 = flake8
MANAGE_PY = python manage.py
DJANGO_ADMIN = django-admin.py
PO_FILES = $(shell find $(PACKAGE) -name '*.po')
MO_FILES = $(PO_FILES:.po=.mo)
all: default
default: build
# Package management
# ==================
# DOC: Remove temporary or compiled files
clean:
find . -type f -name '*.pyc' -delete
find . -type f -path '*/__pycache__/*' -delete
find . -type d -empty -delete
rm -f $(MO_FILES)
@rm -rf tmp_test/
# DOC: Compile files (extensions, message catalogs, etc.)
build: $(MO_FILES)
%.mo: %.po
cd $(abspath $(dir $<)/../../..) && $(DJANGO_ADMIN) compilemessages
# DOC: Install and/or upgrade dependencies
update:
pip install --upgrade pip setuptools
pip install --upgrade -r requirements_dev.txt
pip freeze
release:
fullrelease
.PHONY: all default clean build update release
# Tests and quality
# =================
# DOC: Run tests for all supported versions (creates a set of virtualenvs)
testall:
tox
# DOC: Run tests for the currently installed version
test: build
PYTHONPATH=. python -Wdefault $(TESTS_DIR)/runner.py
# Note: we run the linter in two runs, because our __init__.py files has specific warnings we want to exclude
# DOC: Perform code quality tasks
lint:
$(FLAKE8) --config .flake8 --exclude $(PACKAGE)/__init__.py $(PACKAGE)
$(FLAKE8) --config .flake8 --ignore F401 $(PACKAGE)/__init__.py
$(FLAKE8) --config .flake8 $(TESTS_DIR)
check-manifest
coverage:
$(COVERAGE) erase
$(COVERAGE) run "--include=$(PACKAGE)/*.py,$(TESTS_DIR)/*.py" --branch setup.py test
$(COVERAGE) report "--include=$(PACKAGE)/*.py,$(TESTS_DIR)/*.py"
$(COVERAGE) html "--include=$(PACKAGE)/*.py,$(TESTS_DIR)/*.py"
.PHONY: test testall lint coverage
# Documentation
# =============
# DOC: Compile the documentation
doc:
$(MAKE) -C $(DOC_DIR) html
# DOC: Show this help message
help:
@grep -A1 '^# DOC:' Makefile \
| awk ' \
BEGIN { FS="\n"; RS="--\n"; opt_len=0; } \
{ \
doc=$$1; name=$$2; \
sub("# DOC: ", "", doc); \
sub(":.*", "", name); \
if (length(name) > opt_len) { \
opt_len = length(name) \
} \
opts[NR] = name; \
docs[name] = doc; \
} \
END { \
pat="%-" (opt_len + 4) "s %s\n"; \
asort(opts); \
for (i in opts) { \
opt=opts[i]; \
printf pat, opt, docs[opt] \
} \
}'
.PHONY: doc help