-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
79 lines (53 loc) · 1.72 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
SHELL = /bin/bash
.DEFAULT_GOAL := help
CURRENT_DIR := $(shell pwd)
# Find all python files that are not inside a hidden directory (directory starting with .)
PYTHON_FILES := $(shell find ./* -type f -name "*.py" -print)
# PIPENV files
PIP_FILE = Pipfile
PIP_FILE_LOCK = Pipfile.lock
# Commands
PIPENV_RUN := pipenv run
PYTHON := $(PIPENV_RUN) python3
PIP := $(PIPENV_RUN) pip3
YAPF := $(PIPENV_RUN) yapf
ISORT := $(PIPENV_RUN) isort
PYLINT := $(PIPENV_RUN) pylint
all: help
.PHONY: help
help:
@echo "Usage: make <target>"
@echo
@echo "Possible targets:"
@echo -e " \033[1mSetup TARGETS\033[0m "
@echo "- setup Create the python virtual environment and activate it"
@echo "- dev Create the python virtual environment with developer tools and activate it"
@echo -e " \033[1mFORMATING, LINTING AND TESTING TOOLS TARGETS\033[0m "
@echo "- format Format the python source code"
@echo "- lint Lint the python source code"
@echo "- format-lint Format and lint the python source code"
@echo -e " \033[1mCLEANING TARGETS\033[0m "
@echo "- clean_venv Clean python venv"
# Build targets. Calling setup is all that is needed for the local files to be installed as needed.
.PHONY: dev
dev: $(REQUIREMENTS)
pipenv install --dev
pipenv shell
.PHONY: setup
setup: $(REQUIREMENTS)
pipenv install
pipenv shell
# linting target, calls upon yapf to make sure your code is easier to read and respects some conventions.
.PHONY: format
format:
$(YAPF) -p -i --style .style.yapf $(PYTHON_FILES)
$(ISORT) $(PYTHON_FILES)
.PHONY: lint
lint:
$(PYLINT) $(PYTHON_FILES)
.PHONY: format-lint
format-lint: format lint
# Clean targets
.PHONY: clean_venv
clean_venv:
pipenv --rm