-
Notifications
You must be signed in to change notification settings - Fork 95
/
Makefile
106 lines (77 loc) · 2.86 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
# Usage: export VIRTUAL_ENV=/data/env/itsm/
# make help
SHELL := /bin/sh
# SET THIS! Directory containing wsgi.py
PROJECT := 'itsm'
BK_ENV := 'development'
# VIRTUAL_ENV = ${$(shell which python)%/bin*}
# VIRTUAL_ENV := /data/env/itsm
LOCALPATH := .
PYTHONPATH := $(VIRTUAL_ENV)/bin
PYTHON_BIN := $(PYTHONPATH)/python
SETTINGS := settings
DJANGO_SETTINGS_MODULE = $(SETTINGS)
DJANGO_POSTFIX := --settings=$(DJANGO_SETTINGS_MODULE) --pythonpath=$(PYTHONPATH)
TEST_SETTINGS := settings
DJANGO_TEST_SETTINGS_MODULE = $(TEST_SETTINGS)
DJANGO_POSTFIX := --settings=$(DJANGO_SETTINGS_MODULE) --pythonpath=$(PYTHONPATH)
DJANGO_TEST_POSTFIX := --settings=$(DJANGO_TEST_SETTINGS_MODULE) --pythonpath=$(PYTHONPATH)
.PHONY: clean showenv coverage test pip virtualenv virtual_env_set
showenv:
@echo 'Environment:'
@echo '-----------------------'
@$(PYTHON_BIN) -c "import sys; print 'sys.path:', sys.path"
@echo 'PYTHONPATH:' $(PYTHONPATH)
@echo 'PROJECT:' $(PROJECT)
@echo 'DJANGO_SETTINGS_MODULE:' $(DJANGO_SETTINGS_MODULE)
@echo 'DJANGO_TEST_SETTINGS_MODULE:' $(DJANGO_TEST_SETTINGS_MODULE)
pip: virtual_env_set
pip install -r requirements.txt
virtualenv:
virtualenv --no-site-packages $(VIRTUAL_ENV)
echo $(VIRTUAL_ENV)
djangohelp: virtual_env_set
$(PYTHON_BIN) manage.py help $(DJANGO_POSTFIX)
migrate: virtual_env_set
$(PYTHON_BIN) manage.py migrate $(DJANGO_POSTFIX)
$(PYTHON_BIN) manage.py createcachetable django_cache
collectstatic: virtual_env_set
-mkdir -p .$(LOCALPATH)/static
$(PYTHON_BIN) manage.py collectstatic -c --noinput $(DJANGO_POSTFIX)
runserver: virtual_env_set
$(PYTHON_BIN) manage.py runserver $(DJANGO_POSTFIX)
start_celery: virtual_env_set
$(PYTHON_BIN) manage.py celery worker $(DJANGO_POSTFIX)
clean_task: virtual_env_set
$(PYTHON_BIN) manage.py celery purge -f $(DJANGO_POSTFIX)
dbshell: virtual_env_set
$(PYTHON_BIN) manage.py dbshell $(DJANGO_POSTFIX)
shell_plus: virtual_env_set
$(PYTHON_BIN) manage.py shell_plus $(DJANGO_POSTFIX)
reset_db: virtual_env_set
$(PYTHON_BIN) manage.py reset_db --noinput $(DJANGO_POSTFIX)
icheck:
isort -rc -ac -df .
isort:
isort -rc -ac .
rsync:
rsync -avz --checksum --exclude-from .gitignore --exclude-from .rsyncignore . ${REMOTE_URI}
compare:
rsync -avz --checksum --dry-run --exclude-from .gitignore --exclude-from .rsyncignore . ${REMOTE_URI}
clean:
# find . -name "*.pyc" -print0 | xargs -0 rm -rf
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
-rm -rf htmlcov
-rm -rf .coverage
-rm -rf build
-rm -rf dist
-rm -rf src/*.egg-info
-rm -rf ../templates_module
-rm -rf .cache
git_clean: clean
git clean -fdx -e .idea -e config -e static/assets
test: clean virtual_env_set
-$(PYTHON_PATH)/coverage run $(PYTHON_BIN) manage.py test $(APP) $(DJANGO_TEST_POSTFIX)
coverage: virtual_env_set
$(PYTHON_PATH)/coverage html --include="$(LOCALPATH)/*" --omit="*/admin.py,*/test*"
all: collectstatic