-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (64 loc) · 2.26 KB
/
Copy pathMakefile
File metadata and controls
85 lines (64 loc) · 2.26 KB
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
#!/usr/bin/make -f
TOPDIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
SELF := $(abspath $(lastword $(MAKEFILE_LIST)))
GITHUB_RUN_ID ?= 0
DATE := $(shell date +"%Y%m%d")
VERSION := $(shell git describe --tags --always --match='v[0-9]*' | cut -d '-' -f 1 | tr -d 'v')
RELEASE := $(shell git describe --tags --always --match='v[0-9]*' --long | cut -d '-' -f 2)
BUILD := $(shell git describe --tags --long --always --dirty)-$(DATE)-$(GITHUB_RUN_ID)
define __VERSION_CONTENT__
"""
Dynamic version info
Generated by $(SELF)
on $(shell hostname)
at $(shell date +"%Y-%m-%d %H:%M:%S %Z")
"""
__version__ = '$(VERSION)'
__release__ = '$(RELEASE)'
__build__ = '$(BUILD)'
endef
export __VERSION_CONTENT__
SHOW_ENV_VARS = \
VERSION \
RELEASE \
GITHUB_RUN_ID \
BUILD
help: ## Show help message (list targets)
@awk 'BEGIN {FS = ":.*##"; printf "\nTargets:\n"} /^[$$()% 0-9a-zA-Z_-]+:.*?##/ {printf " \033[36m%-13s\033[0m %s\n", $$1, $$2}' $(SELF)
show-var-%:
@{ \
escaped_v="$(subst ",\",$($*))" ; \
if [ -n "$$escaped_v" ]; then v="$$escaped_v"; else v="(undefined)"; fi; \
printf "%-13s %s\n" "$*" "$$v"; \
}
show-env: $(addprefix show-var-, $(SHOW_ENV_VARS)) ## Show environment details
.PHONY: version
version:
@printf "%s\n" "$(VERSION)" >VERSION
build: version ## Build a module with python -m build
tox run -e build
test: version ## Run tests
tox run
lint: version ## Run linters
tox run -e lint
fmt: version ## Run formatters
tox run -e fmt
.venv:
tox devenv --list-dependencies .venv
venv: .venv ## Create virtualenv
venv-examples: venv ## Install extra modules for examples
$(TOPDIR)/.venv/bin/python3 -m pip install -r $(TOPDIR)/examples/requirements.txt
nltk_data: venv-examples ## Download nltk data required for examples
mkdir -p $(TOPDIR)/.venv/nltk_data
NLTK_DATA="$(TOPDIR)/.venv/nltk_data" $(TOPDIR)/.venv/bin/python3 -m textblob.download_corpora
clean: ## Clean up
find $(TOPDIR)/ -type f -name "*.pyc" -delete
find $(TOPDIR)/ -type f -name "*.pyo" -delete
find $(TOPDIR)/ -type d -name "__pycache__" -delete
for dir in .pytest_cache .tox build dist htmlcov src/wordsearch.egg-info; do \
rm -rf $(TOPDIR)/$${dir} ; \
done
rm -f $(TOPDIR)/.coverage
rm -rf $(TOPDIR)/htmlcov-py*
rm -f $(TOPDIR)/VERSION
.PHONY: build test lint fmt clean