forked from dimier/python-daemon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (100 loc) · 3.28 KB
/
Makefile
File metadata and controls
113 lines (100 loc) · 3.28 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
#
# Makefile by Carl J. Nobile
#
include include.mk
PREFIX = $(shell pwd)
PACKAGE_DIR = $(shell echo $${PWD\#\#*/})
DISTNAME = $(PACKAGE_DIR)-$(VERSION)
LOGS_DIR = $(PREFIX)/logs
DOCS_DIR = $(PREFIX)/docs
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 {} \;
COVERAGE_DIR = $(PREFIX)/.coverage_tests
COVERAGE_FILE = $(PREFIX)/.coveragerc
PIP_ARGS = # Pass var for pip install.
TEST_PATH = # The path to run tests on.
TEST_TAG = # The path to run tests on.
#----------------------------------------------------------------------
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 '^$@$$'
.PHONY : tar
tar : clean
@(cd ..; tar -czvf $(DISTNAME).tar.gz --exclude=".git" \
--exclude="__pycache__" --exclude="logs/*.log" --exclude="dist/*" \
$(PACKAGE_DIR))
#----------------------------------------------------------------------
# Run all tests
# $ make tests
#
# Run all tests in a specific test file.
# $ make tests TEST_PATH=tests/test_bases.py
#
# Run all tests in a specific test file and class.
# $ make tests TEST_PATH=tests/test_bases.py::TestBases
#
# Run just one test in a specific test file and class.
# $ make tests TEST_PATH=tests/test_bases.py::TestBases::test_version
.PHONY : tests
tests : clean
@rm -rf $(DOCS_DIR)/htmlcov
@mkdir -p $(LOGS_DIR)
@coverage erase --rcfile=$(COVERAGE_FILE)
@coverage run --rcfile=$(COVERAGE_FILE) -m pytest --capture=fd -s \
$(TEST_PATH)
@coverage report --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
#----------------------------------------------------------------------
# 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
#
# The tarball would then be named python-daemon-2.0.0rc1.tar.gz
#
.PHONY : build
build : export PR_TAG=$(TEST_TAG)
build : clobber
@./config.py
hatch build dist
.PHONY : upload
upload : build
hatch publish --repo main dist/*
# twine upload --repository pypi dist/*
.PHONY : upload-test
upload-test: build
hatch publish --repo test dist/*
# twine upload --verbose --repository testpypi dist/*
#----------------------------------------------------------------------
.PHONY : install-dev
install-dev:
pip install $(PIP_ARGS) -r requirements/development.txt
#----------------------------------------------------------------------
.PHONY : clean
clean :
$(shell $(RM_CMD))
@rm -rf *.egg-info
@rm -rf dist
.PHONY : clobber
clobber : clean
@rm -f $(LOGS_DIR)/*.log
@rm -f $(LOGS_DIR)/*.pid
@rm -f $(LOGS_DIR)/*.txt
@rm -rf __pycache__
@rm -rf build *.egg-info