1
- SRCPATH := $(CURDIR )
2
- PROJECTNAME := $(shell basename $(CURDIR ) )
1
+ PROJECT_NAME := $(shell basename $CURDIR)
2
+ VIRTUAL_ENVIRONMENT := $(CURDIR ) /.venv
3
+ LOCAL_PYTHON := $(VIRTUAL_ENVIRONMENT ) /bin/python3
3
4
4
5
define HELP
5
- Manage $(PROJECTNAME ) . Usage:
6
-
7
- make run - Run $(PROJECTNAME ) .
8
- make deploy - Install requirements and run app for the first time.
9
- make update - Update pip dependencies via Python Poetry.
10
- make format - Format code with Python's `Black` library.
11
- make lint - Check code formatting with flake8
6
+ Manage $(PROJECT_NAME ) . Usage:
7
+
8
+ make run - Run $(PROJECT_NAME ) .
9
+ make install - Create virtual env, install dependencies, and run project.
10
+ make deploy - Install and run script by running `make install` and `make run` in succession.
11
+ make update - Update pip dependencies via Poetry and export output to requirements.txt.
12
+ make format - Format code with Pythons `Black` library.
13
+ make lint - Check code formatting with `flake8`.
12
14
make clean - Remove cached files and lock files.
15
+
13
16
endef
14
17
export HELP
15
18
16
- .PHONY : run deploy update format lint clean help
17
19
20
+ .PHONY : run install deploy update format lint clean help
18
21
19
22
requirements : .requirements.txt
20
- env : .venv/bin/activate
23
+ env : ./. venv/bin/activate
21
24
22
25
23
26
.requirements.txt : requirements.txt
@@ -30,35 +33,57 @@ all help:
30
33
31
34
.PHONY : run
32
35
run : env
33
- $(shell . .venv/bin/activate && flask run)
36
+ flask run
37
+
38
+
39
+ .PHONY : install
40
+ install :
41
+ if [ ! -d " ./.venv" ]; then python3 -m venv $( VIRTUAL_ENVIRONMENT) ; fi
42
+ . .venv/bin/activate
43
+ $(LOCAL_PYTHON ) -m pip install --upgrade pip setuptools wheel
44
+ $(LOCAL_PYTHON ) -m pip install -r requirements.txt
34
45
35
46
36
47
.PHONY : deploy
37
48
deploy :
38
- $(shell . ./deploy.sh)
49
+ make install
50
+ make run
39
51
40
52
41
53
.PHONY : update
42
- update : env
43
- .venv/bin/python3 -m pip install -U pip
54
+ update :
55
+ if [ ! -d " ./.venv" ]; then python3 -m venv $( VIRTUAL_ENVIRONMENT) ; fi
56
+ .venv/bin/python3 -m pip install --upgrade pip setuptools wheel
44
57
poetry update
45
58
poetry export -f requirements.txt --output requirements.txt --without-hashes
46
59
47
60
48
61
.PHONY : format
49
62
format : env
50
- $(shell . .venv/bin/activate && isort ./)
51
- $(shell . .venv/bin/activate && black ./)
63
+ isort --multi-line=3 .
64
+ black .
65
+
66
+
67
+ .PHONY : lint
68
+ lint :
69
+ flake8 . --count \
70
+ --select=E9,F63,F7,F82 \
71
+ --exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs \
72
+ --show-source \
73
+ --statistics
52
74
53
75
54
76
.PHONY : clean
55
77
clean :
56
78
find . -name ' *.pyc' -delete
57
79
find . -name ' __pycache__' -delete
58
80
find . -name ' poetry.lock' -delete
59
- find . -name ' Pipefile.lock' -delete
60
- find . -name ' logs/*.json' -delete
61
81
find . -name ' *.log' -delete
62
- find . -name ' */.pytest_cache' -delete
63
- find . -name ' */logs/*.json' -delete
64
- rm -rf tests/.pytest_cache
82
+ find . -name ' .DS_Store' -delete
83
+ find . -wholename ' logs/*.json' -delete
84
+ find . -wholename ' .pytest_cache' -delete
85
+ find . -wholename ' **/.pytest_cache' -delete
86
+ find . -wholename ' ./logs/*.json' -delete
87
+ find . -wholename ' ./logs' -delete
88
+ find . -wholename ' *.html' -delete
89
+ find . -wholename ' **/.webassets-cache' -delete
0 commit comments