-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
90 lines (66 loc) · 2.22 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
PROJECT_NAME := $(shell basename $CURDIR)
VIRTUAL_ENVIRONMENT := $(CURDIR)/.venv
LOCAL_PYTHON := $(VIRTUAL_ENVIRONMENT)/bin/python3
define HELP
Manage $(PROJECT_NAME). Usage:
make run - Run $(PROJECT_NAME).
make install - Create virtual env, install dependencies, and run project.
make deploy - Install and run script by running `make install` and `make run` in succession.
make update - Update pip dependencies via Poetry and export output to requirements.txt.
make format - Format code with Python's `Black` library.
make lint - Check code formatting with `flake8`.
make clean - Remove cached files and lock files.
endef
export HELP
.PHONY: run install deploy update format lint clean help
requirements: .requirements.txt
env: ./.venv/bin/activate
.requirements.txt: requirements.txt
$(shell . .venv/bin/activate && pip install -r requirements.txt)
all help:
@echo "$$HELP"
.PHONY: run
run: env
python3 main.py
.PHONY: install
install:
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
. .venv/bin/activate
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel
$(LOCAL_PYTHON) -m pip install -r requirements.txt
.PHONY: deploy
deploy:
make install
make run
.PHONY: update
update:
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
.venv/bin/python3 -m pip install --upgrade pip setuptools wheel
poetry update
find . -name 'requirements.txt' -delete
poetry export -f requirements.txt --output requirements.txt --without-hashes
.PHONY: format
format: env
isort --multi-line=3 .
black .
.PHONY: lint
lint:
flake8 . --count \
--select=E9,F63,F7,F82 \
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs \
--show-source \
--statistics
.PHONY: clean
clean:
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete
find . -name 'poetry.lock' -delete
find . -name '*.log' -delete
find . -name '.DS_Store' -delete
find . -wholename 'logs/*.json' -delete
find . -wholename './.pytest_cache' -delete
find . -wholename './.venv' -delete
find . -wholename '**/.pytest_cache' -delete
find . -wholename './logs/*.json' -delete
find . -wholename './logs' -delete
find . -wholename './export/*.csv' -delete