-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
118 lines (82 loc) · 2.98 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
VENV=.venv
SHELL=/bin/bash
python=$(VENV)/bin/python3
pip=$(VENV)/bin/python -m pip
django=$(python) manage.py
# Utility scripts to prettify echo outputs
bold := '\033[1m'
sgr0 := '\033[0m'
HOST?=localhost
PORT?=8000
.PHONY: bootstrap clean venv requirements develop develop-lab production
bootstrap: venv develop
bootstrap-prod: venv production
clean:
@echo -e $(bold)Clean up old virtualenv and cache$(sgr0)
@rm -rf $(VENV) *.egg-info .pytest_cache
venv: clean
@echo -e $(bold)Create virtualenv$(sgr0)
@python3 -m venv $(VENV)
@$(pip) install --upgrade pip pip-tools
requirements:
@echo -e $(bold)Create requirements with pip-tools$(sgr0)
@$(VENV)/bin/pip-compile -vU --resolver backtracking -o requirements.txt pyproject.toml
@$(VENV)/bin/pip-compile -vU --resolver backtracking --extra dev -o requirements.dev.txt pyproject.toml
@$(VENV)/bin/pip-compile -vU --resolver backtracking --extra lab -o requirements.lab.txt pyproject.toml
develop:
@echo -e $(bold)Install and update development requirements$(sgr0)
@$(pip) install -r requirements.dev.txt
develop-lab:
@echo -e $(bold)Install and update jupyter requirements$(sgr0)
@$(pip) install -r requirements.lab.txt
production:
@echo -e $(bold)Install and update production requirements$(sgr0)
@$(pip) install -r requirements.txt
# Django development commands
.PHONY: lab serve test shell
serve:
@$(django) runscript show_settings
@$(django) runserver $(HOST):$(PORT)
lab:
@# see: https://docs.djangoproject.com/en/4.2/topics/async/
@DJANGO_ALLOW_ASYNC_UNSAFE=1 $(django) shell_plus --lab
test:
@$(python) -m pytest
shell:
@$(django) shell
# Django production commands
.PHONY: collectstatic
collectstatic:
@$(django) collectstatic --ignore=*.scss
@$(django) compilescss --use-storage
# Django database commands
.PHONY: bootstrap-django clean-django demo migrate migrations secret_key superuser sqlite-bootstrap
bootstrap-django: clean-django secret_key sqlite-bootstrap migrate superuser
clean-django:
@rm -rf db.sqlite3 .media .static
demo:
@LOGURU_LEVEL=INFO $(django) runscript init_demo
migrate:
@echo -e $(bold)Apply migration to database$(sgr0)
@$(django) migrate
migrations:
@echo -e $(bold)Create migration files$(sgr0)
@$(django) makemigrations
secret_key:
@$(python) scripts/generate_secret_key.py
superuser:
@echo -e $(bold)Creating superuser account 'admin'$(sgr0)
@$(django) createsuperuser --username=admin [email protected]
sqlite-bootstrap:
@echo -e $(bold)Prepare SQLite db with GeoDjango enabled$(sgr0)
# Temporary solution for https://code.djangoproject.com/ticket/32935
@$(django) shell -c "import django;django.db.connection.cursor().execute('SELECT InitSpatialMetaData(1);')";
.PHONY: db-flush db-demo
db-flush:
@echo -e $(bold)Deleting all data from database$(sgr0)
@$(django) flush
db-demo: db-flush superuser
@echo -e $(bold)Loading demo data$(sgr0)
@$(django) loaddata website/demo
@$(django) loaddata website/demo_places_202309
@LOGURU_LEVEL=INFO $(django) runscript add_demo_shares