-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
116 lines (88 loc) · 3.97 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
# Self-Documented Makefile see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.DEFAULT_GOAL := help
PYTHON := /usr/bin/env python3
MANAGE_PY := $(PYTHON) manage.py
PYTHON_PIP := /usr/bin/env pip3
PIP_COMPILE := /usr/bin/env pip-compile
PART := patch
PACKAGE_VERSION = $(shell $(PYTHON) setup.py --version)
# Put it first so that "make" without argument is like "make help".
help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-32s-\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: help
guard-%: ## Checks that env var is set else exits with non 0 mainly used in CI;
@if [ -z '${${*}}' ]; then echo 'Environment variable $* not set' && exit 1; fi
# --------------------------------------------------------
# ------- Python package (pip) management commands -------
# --------------------------------------------------------
clean-build: ## Clean project build artifacts.
@echo "Removing build assets..."
@$(PYTHON) setup.py clean
@rm -rf build/
@rm -rf dist/
@rm -rf *.egg-info
install-wheel: clean-build ## Install wheel
@echo "Installing wheel"
@$(PYTHON_PIP) install wheel
install: clean-build install-wheel ## Install project dependencies.
@echo "Installing project in dependencies..."
@$(PYTHON_PIP) install -r requirements.txt
install-deploy: clean-build install-wheel ## Install deploy extra dependencies.
@echo "Installing deploy extra requirements..."
@$(PYTHON_PIP) install -e .'[deploy]'
install-lint: clean-build install-wheel ## Install lint extra dependencies.
@echo "Installing lint extra requirements..."
@$(PYTHON_PIP) install -e .'[lint]'
install-test: clean-build install-wheel ## Install test extra dependencies.
@echo "Installing test extra requirements..."
@$(PYTHON_PIP) install -e .'[test]'
install-dev: clean-build install-wheel ## Install development extra dependencies.
@echo "Installing development requirements..."
@$(PYTHON_PIP) install -e .'[development]' -r requirements.txt
update-requirements: ## Updates the requirement.txt adding missing package dependencies
@echo "Syncing the package requirements.txt..."
@$(PIP_COMPILE)
# ----------------------------------------------------------
# --------- Django manage.py commands ----------------------
# ----------------------------------------------------------
run: compilemessages makemessages ## Run the run_server using default host and port
@$(MANAGE_PY) runserver 127.0.0.1:8090
migrate: ## Run the migrations
@$(MANAGE_PY) migrate
migrations: ## Generate the migrations
@$(MANAGE_PY) makemigrations
makemessages: clean-build ## Runs over the entire source tree of the current directory and pulls out all strings marked for translation.
@$(MANAGE_PY) makemessages --locale=en_US --ignore=".tox*" --ignore="venv*"
@$(MANAGE_PY) makemessages --locale=fr --ignore=".tox*" --ignore="venv*"
compilemessages: clean-build ## Compiles .po files created by makemessages to .mo files for use with the built-in gettext support.
@$(MANAGE_PY) compilemessages --ignore=".tox*" --ignore="venv*"
# ----------------------------------------------------------
# ---------- Release the project to PyPI -------------------
# ----------------------------------------------------------
increase-version: guard-PART ## Increase project version
@bump2version $(PART)
@git switch -c main
dist: clean install-deploy ## builds source and wheel package
@pip install twine==3.4.1
@python setup.py sdist bdist_wheel
release: dist ## package and upload a release
@twine upload dist/*
# ----------------------------------------------------------
# --------- Run project Test -------------------------------
# ----------------------------------------------------------
test: install-test
@pytest -v
tox: install-test ## Run tox test
@tox
clean-test-all: clean-build ## Clean build and test assets.
@rm -rf .tox/
@rm -rf .pytest_cache/
@rm -f test.db
lint:
isort .
flake8 .
create-docs:
@npx docsify init ./docs
serve-docs:
@npx docsify serve ./docs
clean: clean-test-all clean-build