-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (54 loc) · 1.83 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
VENV = venv
VENV_PYTHON = $(VENV)/bin/python
SYSTEM_PYTHON = $(or $(shell which python3), $(shell which python))
# If virtualenv exists, use it. If not, find python using PATH
#PYTHON = $(or $(wildcard $(VENV_PYTHON)), $(SYSTEM_PYTHON))
PYTHON = $(VENV_PYTHON)
PIP = $(dir $(PYTHON))pip
PKG_NAME = $(shell grep -A 1 '\[project\]' pyproject.toml | grep 'name' | sed 's/.*=\s*//' | sed 's/"//g')
MOD_NAME = $(shell echo $(PKG_NAME)| sed 's/-/_/g')
.PHONY: clean deps deps-dev dev dist lint pkg-name test venv debug systemd-install systemd-remove
.SILENT: pkg-name
default: dist
deps: venv
$(PIP) install -r requirements.txt
deps-dev: deps
$(PIP) install -r requirements-dev.txt
#dist: venv deps deps-dev test
dist:
$(PIP) install build
$(PYTHON) -m build --sdist
$(PYTHON) -m build --wheel
lint: venv
$(PYTHON) -m flake8 $(MOD_NAME)
$(PYTHON) -m flake8 tests/
dev: pkg-name venv deps deps-dev
$(PIP) show $(PKG_NAME) > /dev/null || $(PIP) install -e .
pkg-name:
if [ -z "$(PKG_NAME)" ]; then \
echo "Project name could not be found. Please make sure the 'name' field is the first line within the [project] section of your pyproject.toml"; \
exit 1; \
else \
echo "Project name is: '$(PKG_NAME)'"; \
fi
test: deps-dev dev
$(PYTHON) -m pytest
# Dev/build environment
$(VENV_PYTHON):
$(SYSTEM_PYTHON) -m venv $(VENV)
venv: $(VENV_PYTHON)
debug: venv
$(VENV)/bin/flask --app $(MOD_NAME)/__init__.py --debug run --host=0.0.0.0 --port=8080
systemd-install:
sudo cp systemd/$(PKG_NAME).service /etc/systemd/system
sudo systemctl daemon-reload
systemd-remove:
sudo systemctl stop $(PKG_NAME).service
sudo rm /etc/systemd/system/$(PKG_NAME).service
sudo systemctl daemon-reload
clean:
find . -type f -name *.pyc -delete
find . -type d -name __pycache__ -delete
rm -rf src/*.egg-info
rm -rf dist
rm -rf $(VENV)