-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
66 lines (48 loc) · 2.15 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
#!/usr/bin/env make
.PHONY: usage setup-env lint telegram \
win-setup-venv win-telegram win-cleanup \
container-build container-telegram container-bash container-lint container-clean
VENV_DIR := .venv
VENV_RUN := . $(VENV_DIR)/bin/activate
CONTAINER_IMAGE := 'pybot'
CONTAINER_ENGINE ?= $(which docker)
CONTAINER_BUILD := $(CONTAINER_ENGINE) build . -t $(CONTAINER_IMAGE)
CONTAINER_RUN_DIRS := -v "$(CURDIR):/usr/src/pybot" -w /usr/src/pybot
CONTAINER_RUN_FLAGS := -it --rm --name pybot $(CONTAINER_RUN_DIRS) $(CONTAINER_IMAGE)
CONTAINER_RUN := $(CONTAINER_ENGINE) run $(CONTAINER_RUN_FLAGS)
PYTHON_LINT := pep8 --max-line-length=120 --exclude=$(VENV_DIR),dist .
PYBOT_TELEGRAM := bin/pybot telegram
usage: ## Show this help
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
setup-venv: ## Setup virtualenv
(test `which virtualenv` || python3 -m pip install --upgrade virtualenv)
(test -e $(VENV_DIR) || python3 -m venv $(VENV_DIR))
($(VENV_RUN) && python3 -m pip install --upgrade pip)
(test ! -e requirements.txt || ($(VENV_RUN) && pip install -r requirements.txt))
clean:
rm -rf $(VENV_DIR)
lint: ## Run code linter to check code style
($(VENV_RUN); $(PYTHON_LINT))
telegram: ## Run pybot with the telegram adapter
($(VENV_RUN); exec $(PYBOT_TELEGRAM))
win-setup-venv: ## Setup virtualenv in windows
pip install virtualenv
virtualenv .venv
.venv\Scripts\activate
pip install --upgrade pip
pip install -r requirements.txt
win-telegram: ## Run pybot with the telegram adapter in windows
.venv\Scripts\activate
python bin\pybot telegram
win-cleanup: ## Remove .venv dir
rmdir /s /q .venv
container-build: ## Build the container image for running pybot
$(CONTAINER_BUILD)
container-telegram: ## Run with telegram adapter in the container container
$(CONTAINER_RUN) $(PYBOT_TELEGRAM)
container-bash: ## Run bash in the container container
$(CONTAINER_RUN) bash
container-lint: ## Run pep8 in the container container
$(CONTAINER_RUN) $(PYTHON_LINT)
container-clean: ## Remove the container image
$(CONTAINER_ENGINE) rmi $(CONTAINER_IMAGE)