-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
71 lines (50 loc) · 1.75 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
DEFAULT_PY_VERSION=3.7.0
CC=python
DOCKER_COMPOSE=docker-compose
DEFAULT_HOST=localhost:8000
MANAGE_PATH=src/manage.py
REQUIREMENTS_PATH=requirements.txt
DEV_REQUIREMENTS_PATH=requirements/dev.txt
# If the first argument is "docker-up"...
ifeq (docker-up,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
.PHONY: build clean test help default
default: test
help:
@echo 'Management commands for Django project:'
@echo
@echo 'Usage:'
@echo ' make test Run tests on the project.'
@echo ' make clean Clean the directory tree.'
@echo ' make run Run Django server.'
@echo ' make docker-up Run docker with RUN_ARGS or all by default.'
@echo ' make install-req Install default requirements.'
@echo ' make install-dev-req Install default requirements and dev requirements.'
@echo ' make install-python Install python ${DEFAULT_PY_VERSION}'
@echo
clean:
find . -name "*.pyc" -exec rm -f {} \;
test:
pytest
run: clean
${CC} ${MANAGE_PATH} runserver ${DEFAULT_HOST}
docker-up:
${DOCKER_COMPOSE} up $(RUN_ARGS)
install-req:
${CC} -m pip install -r ${REQUIREMENTS_PATH}
install-dev-req: install-req
${CC} -m pip install -r ${DEV_REQUIREMENTS_PATH}
info:
$(info shell 'PATH' is ${PATH})
check-binaries:
EXECUTABLES = docker python pyenv brew
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
install-python: info check-binaries
-pyenv install ${DEFAULT_PY_VERSION}
test -f .python-version && rm .python-version
echo ${DEFAULT_PY_VERSION} >> .python-version