-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
134 lines (97 loc) · 3.02 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# update-conf-py-do-not-use Makefile
PACKAGE=update_conf_py_do_not_use
NAME=update-conf-py-do-not-use
CONF=$(NAME).conf
PREFIX=/usr/local
ETC=/etc
VENV=venv
TEST_PACKAGE=tests
VERSION=$(shell python setup.py --version)
all: help
help:
@echo "Usage:"
@echo
@echo " make install install project in system (global)"
@echo " make install-develop install project in develop mode (virtual env with test and build tools)"
@echo " make check run checks (like PEP8 compliance)"
@echo " make test run tests (use 'sudo' to run all)"
@echo " make test-with-coverage run tests with coverage (use 'sudo' to run all)"
@echo " make coverage-report generate coverage report in html"
@echo " make build build (sdist and bdist_wheel)"
@echo " make check-and-test-publish run checks and test the process of publishing a version (using Test PyPI)"
@echo " make tag-for-publish push tag version on GitHub (which triggers the CI/CD pipeline to publish the version on PyPI (plus Code Artifact)"
@echo " make clean cleanup temporary files"
# Install
install:
python setup.py install
# Development
install-develop:
python3 -m venv $(VENV)
. $(VENV)/bin/activate && python -m pip install -r requirements-dev.txt
. $(VENV)/bin/activate && python setup.py develop
@echo
@echo "Environment setup done. Remember to activate your virtual env."
@echo
@tput setaf 2
@echo " . $(VENV)/bin/activate"
@tput sgr0
# Tests and checks
check:
check-manifest
flake8 $(PACKAGE) $(TEST_PACKAGE)
test:
python setup.py test
test-with-coverage:
coverage run setup.py test
coverage-report:
coverage html
@echo
@echo "Check coverage results at"
@echo
@tput setaf 2
@echo " http://localhost:8000"
@tput sgr0
@echo
cd htmlcov && python -m http.server
check-build:
check-wheel-contents dist/*.whl
python -m twine check dist/*
install-from-testpipy:
python3 -m venv $(VENV)
. $(VENV)/bin/activate && python -m pip install -i https://test.pypi.org/simple/ $(NAME)==$(VERSION)
# Build
build: clean-build clean-dist
python setup.py sdist bdist_wheel
# Test publish
publish-testpypi:
twine upload -r testpypi dist/*
check-and-test-publish: build check-build publish-testpypi
@echo
@echo "Test of publishing on Test PyPI done. If necessary, remember to test install from Test PyPI."
@echo
@tput setaf 2
@echo " deactivate"
@echo " rm -Rf $(VENV)"
@echo " make install-from-testpypi"
@tput sgr0
# Tag for publish
# It will trigger a CI/CD pipeline that will ending up on publishing on PyPI
# and AWS CodeArtifact.
tag-for-publish:
git tag "v$(VERSION)"
git push origin "v$(VERSION)"
# Clean
clean-build:
python setup.py clean --all
clean-dist:
rm -Rf dist
clean-egg:
rm -Rf *.egg-info
rm -Rf .eggs
clean-coverage:
rm -f .coverage
rm -f coverage.lcov
rm -Rf htmlcov
clean-pyc:
find . -name "*.pyc" -type f -delete
clean: clean-build clean-dist clean-egg clean-coverage clean-pyc