-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
87 lines (77 loc) · 2.17 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
TEST_DIR=tests
#PYPI_URL=https://test.pypi.org/legacy/
PYPI_URL=https://upload.pypi.org/legacy/
DEFAULT_PYTHON_VERSION=three
## Sets up the virtual environment via pipenv.
.PHONY: setup
setup:
pipenv --$(DEFAULT_PYTHON_VERSION) install --dev
## Removes everything including virtual environments.
.PHONY: clean
clean: mostlyclean
-pipenv --rm
rm -f Pipfile.lock
## Removes test and packaging outputs.
.PHONY: mostlyclean
mostlyclean:
rm -rf .coverage htmlcov/ .pytest_cache/ build/ dist/
## Runs tests.
.PHONY: test
test:
pipenv run pytest $(TEST_DIR) -v -s --disable-warnings
## Creates coverage report.
.PHONY: coverage
coverage:
pipenv run pytest --cov=src/ --cov-report=term-missing --cov-report=html --disable-warnings
open htmlcov/index.html || xdg-open htmlcov/index.html
## Packages for both Python 2 and 3 for PyPi.
.PHONY: dist
dist: mostlyclean
-pipenv --rm
pipenv --three install --dev --skip-lock
pipenv run python setup.py sdist bdist_wheel
pipenv --rm
pipenv --two install --dev --skip-lock
pipenv run python setup.py sdist bdist_wheel
pipenv --rm
pipenv --$(DEFAULT_PYTHON_VERSION) install --dev
## Uploads packages to PyPi.
.PHONY: upload
upload:
pipenv run twine upload --repository-url $(PYPI_URL) dist/*
## Alias for packaging and upload together.
.PHONY: pypi
pypi: dist upload
## This help message.
.PHONY: help
help:
@printf "\nUsage:\n";
@awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)