-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
76 lines (63 loc) · 2.76 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
.DEFAULT_GOAL:=help
.ONESHELL:
ENV_PREFIX=$(shell python3 -c "if __import__('pathlib').Path('.venv/bin/pip').exists(): print('.venv/bin/')")
USING_PDM=$(shell grep "tool.pdm" pyproject.toml && echo "yes")
PDM_INSTALLED=$(shell if pdm --version > /dev/null; then echo "yes"; fi)
VENV_EXISTS=$(shell python3 -c "if __import__('pathlib').Path('.venv/bin/activate').exists(): print('yes')")
VERSION := $(shell grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
BUILD_DIR=dist
PDM_OPTS ?=
PDM ?= pdm $(PDM_OPTS)
PDM_RUN_BIN = $(PDM) run
.EXPORT_ALL_VARIABLES:
ifndef VERBOSE
.SILENT:
endif
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: upgrade
upgrade: ## Upgrade all dependencies to the latest stable versions
@if [ "$(USING_PDM)" ]; then pdm update; fi
@echo "Python Dependencies Updated"
$(ENV_PREFIX)pre-commit autoupdate
@echo "Updated Pre-commit"
.PHONY: install
install: ## Install the project in dev mode.
@if ! pdm --version > /dev/null; then echo 'pdm is required, installing from from https://pdm.fming.dev/'; curl -sSL https://pdm.fming.dev/install-pdm.py | python3 - ; fi
@if [ "$(VENV_EXISTS)" ]; then echo "Removing existing environment" && rm -Rf .venv; fi
if [ "$(USING_PDM)" ]; then $(PDM) config venv.in_project true && python3 -m venv --copies .venv && source .venv/bin/activate && .venv/bin/pip install -U wheel setuptools cython pip; fi
if [ "$(USING_PDM)" ]; then $(PDM) install -G:all ; fi
@echo "=> Install complete. ** If you want to re-install re-run 'make install'"
.PHONY: clean
clean: ## remove all build, testing, and static documentation files
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
find . -name '.ipynb_checkpoints' -exec rm -fr {} +
find . -name '.terraform' -exec rm -fr {} +
rm -fr .tox/
rm -fr .coverage
rm -fr coverage.xml
rm -fr coverage.json
rm -fr htmlcov/
rm -fr .pytest_cache
rm -fr .mypy_cache
rm -fr site
.PHONY: test
test: ## Test project files
@echo "=> Launching Python test cases..."
@$(ENV_PREFIX)pytest tests/
.PHONY: lint
lint: ## Lint source files
@echo "=> Executing pre-commit..."
@$(ENV_PREFIX)pre-commit run --all-files
.PHONY: build
build: ## Install the project in dev mode.
@echo "=> Building Application..."
@pdm build