-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
105 lines (86 loc) · 2.97 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
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
CURRENT_SIGN_SETTING := $(shell git config commit.gpgSign)
PACKAGE_DIRECTORY=src
TEST_DIRECTORY=tests
LINTING_LINELENGTH=120
STUB_DIRECTORY=stubs
.PHONY: help clean-pyc clean-build isort-test isort darglint-test black-test black stubs mypy-test pytest test format coverage tox
help:
@echo " help: Print this help"
@echo " clean-pyc: Remove python artifacts."
@echo " clean-build: Remove build artifacts."
@echo " isort-test: Test whether import statements are sorted."
@echo " isort: Sort import statements."
@echo " darglint-test: Test whether docstrings are valid."
@echo " black-test: Test whether black formatting is adhered to."
@echo " black: Apply black formatting."
@echo " stubs: Run stub generation."
@echo " mypy-test: Test whether mypy type annotations are sufficient."
@echo " pytest: Run pytest suite."
@echo " test: Run all tests."
@echo " format: Apply all formatting tools."
@echo " profile: Run cProfile on the MCMC example and print longest running functions."
@echo " tox: Run tox testing."
@echo " coverage: Run coverage report."
@echo " release: Build and upload to PyPI."
clean-pyc:
find . -regex '^./\($(PACKAGE_DIRECTORY)\|$(TEST_DIRECTORY)\)/.*\.py[co]' -delete
find . -regex '^./\($(PACKAGE_DIRECTORY)\|$(TEST_DIRECTORY)\)/.*__pycache__' -delete
clean-build:
rm --force --recursive build/
rm --force --recursive dist/
rm --force --recursive *.egg-info
isort-test: clean-pyc
isort \
--recursive \
--check-only \
--line-width $(LINTING_LINELENGTH) \
--multi-line 3 \
--trailing-comma \
$(PACKAGE_DIRECTORY) $(TEST_DIRECTORY)
isort: clean-pyc
isort \
--recursive \
--line-width $(LINTING_LINELENGTH) \
--multi-line 3 \
--trailing-comma \
$(PACKAGE_DIRECTORY) $(TEST_DIRECTORY)
darglint-test:
darglint --docstring-style google --strictness full $(PACKAGE_DIRECTORY) $(TEST_DIRECTORY)
black-test:
black \
--check \
--include "($(PACKAGE_DIRECTORY)/|$(TEST_DIRECTORY)/).*\.pyi?" \
--line-length $(LINTING_LINELENGTH) \
.
black:
black \
--include "($(PACKAGE_DIRECTORY)/|$(TEST_DIRECTORY)/).*\.pyi?" \
--line-length $(LINTING_LINELENGTH) \
.
stubs: clean-pyc
rm -rf $(STUB_DIRECTORY)
stubgen -o $(STUB_DIRECTORY) $(PACKAGE_DIRECTORY)
mypy-test:
mypy $(PACKAGE_DIRECTORY)
pytest:
python -m pytest \
--verbose \
--color=yes \
--cov=$(PACKAGE_DIRECTORY) \
--cov-report term-missing
test: clean-pyc isort-test darglint-test black-test pytest
format: clean-pyc isort black stubs
profile:
python -m cProfile -o .profile.txt "$(TEST_DIRECTORY)/example.py"
python -c "import pstats; s = pstats.Stats('.profile.txt'); print(s.strip_dirs().sort_stats('cumtime').print_stats(20))"
tox:
tox
coverage:
coverage run --include=src/* -m pytest
release: clean-pyc clean-build test
git config commit.gpgSign true
bumpversion $(bump)
git push upstream && git push upstream --tags
python setup.py sdist bdist_wheel
twine upload dist/*
git config commit.gpgSign "$(CURRENT_SIGN_SETTING)"