-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (99 loc) · 3.25 KB
/
Makefile
File metadata and controls
119 lines (99 loc) · 3.25 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#
# Development by Carl J. Nobile
#
# -*-coding: utf-8-*-
include include.mk
PREFIX = $(shell pwd)
BASE_DIR = $(shell basename $(PREFIX))
PACKAGE_DIR = $(BASE_DIR)-$(VERSION)$(TEST_TAG)
DOCS_DIR = $(PREFIX)/docs
LOGS_DIR = $(PREFIX)/logs
TODAY = $(shell date +"%Y-%m-%d_%H%M")
RM_REGEX = '(^.*.pyc$$)|(^.*.wsgic$$)|(^.*~$$)|(.*\#$$)|(^.*,cover$$)'
RM_CMD = find $(PREFIX) -regextype posix-egrep -regex $(RM_REGEX) \
-exec rm {} \;
TEST_TAG =
PIP_ARGS = # Pass var for pip install.
TEST_PATH = # Pass var for test paths.
#----------------------------------------------------------------------
all : help
#----------------------------------------------------------------------
.PHONY: help
help :
@LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : \
2>/dev/null | awk -v RS= \
-F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data \
base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | grep \
-E -v -e '^[^[:alnum:]]' -e '^$@$$'
#
# The tarball would then be named python-thunderborg-2.0.0rc1.tar.gz
#
.PHONY : tar
tar : clean
@(cd ..; tar -czvf $(PACKAGE_DIR).tar.gz --exclude=".git" \
--exclude="__pycache__" --exclude="$(LOGS_DIR)/*.log" \
--exclude="dist/*" $(BASE_DIR))
#----------------------------------------------------------------------
# $ make tests
# $ make tests TEST_PATH=tborg/tests/test_tborgpy::TestThunderBorg
# $ make tests TEST_PATH=tborg/tests/test_tborg.py::TestClassMethods::test_set_i2c_address_without_current_address
.PHONY : tests
tests : clean
@rm -rf $(DOCS_DIR)/htmlcov
@mkdir -p $(LOGS_DIR)
@coverage erase --rcfile=$(COVERAGE_FILE)
# The --omit must be here or tests will be in coverage.
@coverage run --rcfile=$(COVERAGE_FILE) --omit="tborg/tests/*,/usr/*" \
-m pytest --capture=tee-sys $(TEST_PATH)
@coverage report -m --rcfile=$(COVERAGE_FILE)
@coverage html --rcfile=$(COVERAGE_FILE)
@echo $(TODAY)
.PHONY : flake8
flake8 :
# Error on syntax errors or undefined names.
flake8 . --select=E9,F7,F63,F82 --show-source
# Warn on everything else.
flake8 . --exit-zero
.PHONY : sphinx
sphinx : clean
(cd $(DOCS_DIR); make html)
.PHONY : latexpdf
latexpdf:
(cd $(DOCS_DIR); make latexpdf)
.PHONY : epub
epub :
(cd $(DOCS_DIR); make epub)
.PHONY : alldocs
alldocs : sphinx epub latexpdf
# To add a pre-release candidate such as 'rc1' to a test package name an
# environment variable needs to be set that setup.py can read.
#
# make build TEST_TAG=rc1
# make upload-test TEST_TAG=rc1
#
.PHONY : build
build : export PR_TAG=$(TEST_TAG)
build : clean
@./config.py
hatch build dist
.PHONY : upload
upload : clobber build
hatch publish --repo main dist/*
# twine upload --repository pypi dist/*
.PHONY : upload-test
upload-test: clobber build
hatch publish --repo test dist/*
# twine upload --repository testpypi dist/*
.PHONY : install-dev
install-dev:
pip install $(PIP_ARGS) -r requirements/development.txt
.PHONY : install-prd
install-prd:
pip install $(PIP_ARGS) -r requirements/production.txt
#----------------------------------------------------------------------
clean :
$(shell $(RM_CMD))
clobber : clean
@rm -rf dist build *.egg-info
@rm -rf $(DOCS_DIR)/htmlcov
@rm -rf $(DOCS_DIR)/build