forked from compserv/hknweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (58 loc) · 1.69 KB
/
Makefile
File metadata and controls
73 lines (58 loc) · 1.69 KB
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
PIP_HOME = $(shell python3 -c "import site; import os; print(os.path.join(site.USER_BASE, 'bin'))" \
|| python -c "import site; import os; print(os.path.join(site.USER_BASE, 'bin'))")
VENV := .venv
BIN := $(VENV)/bin
PYTHON := $(BIN)/python
MANAGE := HKNWEB_MODE='dev' $(PYTHON) ./manage.py
IP ?= 127.0.0.1
PORT ?= 3000
.PHONY: dev
dev:
$(MANAGE) runserver $(IP):$(PORT)
.PHONY: livereload
livereload:
$(MANAGE) livereload $(IP):$(PORT)
.PHONY: venv
venv:
python3 -m venv $(VENV)
@echo "When developing, activate the virtualenv with 'source .venv/bin/activate' so Python can access the installed dependencies."
.PHONY: install-prod
install-prod:
# For issues with binary packages, consider https://pythonwheels.com/
$(PYTHON) -m pip install --upgrade "pip<=20.3.4"
$(PYTHON) -m pip install --upgrade "setuptools<=51.2.0"
# TODO: pinned/unpinned dependency version.
# See https://hkn-mu.atlassian.net/browse/COMPSERV-110
$(PYTHON) -m pip install -r requirements.txt
.PHONY: install
install:
make install-prod
$(PYTHON) -m pip install -r requirements-dev.txt
.PHONY: createsuperuser superuser
superuser: createsuperuser
createsuperuser:
$(MANAGE) createsuperuser
.PHONY: migrate
migrate:
$(MANAGE) migrate
.PHONY: makemigrations migrations
migrations: makemigrations
makemigrations:
$(MANAGE) makemigrations
.PHONY: shell
shell:
$(MANAGE) shell
.PHONY: test
test: venv
$(BIN)/pytest -v tests/
$(BIN)/pre-commit run --all-files
.PHONY: clean
clean:
rm -rf $(VENV)
.PHONY: mysql
mysql:
mysql -e "CREATE DATABASE IF NOT EXISTS hkn;"
mysql -e "GRANT ALL PRIVILEGES ON hkn.* TO 'hkn'@'localhost' IDENTIFIED BY 'hknweb-dev';"
.PHONY: permissions
permissions:
$(MANAGE) shell < hknweb/init_permissions.py