This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
148 lines (126 loc) · 4.67 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
venv: FORCE
python3 -m venv ~/.venv/cloudmarker
echo . ~/.venv/cloudmarker/bin/activate > venv
# In local development environment, we run `make venv` to create a
# `venv` script that can be used to activate the virtual Python
# environment conveniently by running `. ./venv`.
#
# However, Travis CI creates virtual Python environments on its own for
# each Python version found in the build matrix. Further, in certain
# production environments, we may not want to create virtual Python
# environments.
#
# In both of the above mentioned cases, we do not run `make venv`. But
# most of the commands below start with `. ./venv`, so a `venv` script
# is expected by all the commands. Therefore, we run `touch venv` to
# create an empty `venv` script if none exists. If `venv` already
# exists, then `touch venv` does nothing apart from altering its access
# and modification times.
deps: FORCE
touch venv
. ./venv && pip3 install -r requirements.txt
pip3 freeze
. ./venv && pip3 install -r dev-requirements.txt
pip3 freeze
rmvenv: FORCE
rm -rf ~/.venv/cloudmarker
rm venv
test: FORCE
# Test interactive Python examples in docstrings.
. ./venv && \
find . -name "*.py" ! -path "*/build/*" \
! -name "setup.py" ! -name "__main__.py" | \
xargs -n 1 python3 -m doctest
# Run unit tests.
. ./venv && python3 -m unittest -v
coverage: FORCE
. ./venv && coverage run -m unittest -v
. ./venv && coverage combine
. ./venv && coverage report --show-missing
. ./venv && coverage html
@echo
@echo Coverage report: htmlcov/index.html
# See pylama.ini for pylama configuration. Pylama is configured to
# invoke isort to lint import statements. Pylama prints the files where
# we need to fix the import statements. But it does not tell us the
# details of the changes to be made to fix them.
#
# This is why we invoke isort independently once to show us the changes
# (in diff format) that we need to make to fix the import statements.
# Note that this independently invoked isort exits with exit code 0
# regardless of whether it finds problems with import statements or not.
lint:
. ./venv && isort --quiet --diff --skip-glob "*/build/*" .
. ./venv && pylama
# The -M option for sphinx-apidoc puts the package documentation before
# submodules documentation. Without it, the package documentation is
# placed after submodules documentation.
docs: FORCE
rm -rf docs/api docs/_build
. ./venv && sphinx-apidoc -M -o docs/api cloudmarker cloudmarker/test
sed 's/^cloudmarker/Cloudmarker API/; s/^==*/===============/' \
docs/api/modules.rst > modules.tmp
mv modules.tmp docs/api/modules.rst
. ./venv && cd docs && make html
@echo
@echo Generated documentation: docs/_build/html/index.html
checks: test coverage lint docs
# Targets to build and upload a new release.
freeze: rmuservenv uservenv
. ./uservenv && pip3 install -r usr-requirements.txt
. ./uservenv && pip3 freeze > pkg-requirements.txt
dist: clean
. ./venv && python3 setup.py sdist bdist_wheel
. ./venv && twine check dist/*
upload: FORCE
. ./venv && twine upload dist/*
test-upload: FORCE
. ./venv && \
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
# Create a new virtual environment to check `pip3 install cloudmarker`
# works fine from a user's perspective.
uservenv: FORCE
python3 -m venv ~/.venv/cloudmarker-user
echo . ~/.venv/cloudmarker-user/bin/activate > uservenv
rmuservenv: FORCE
rm -rf ~/.venv/cloudmarker-user
rm -f uservenv
verify-upload: verify-sdist verify-bdist
verify-sdist:
@echo
@echo Testing source distribution from PyPI ...
@echo
make smoke-test PIP_OPTS="--no-binary :all:"
verify-bdist:
@echo
@echo Testing wheel distribution from PyPI ...
@echo
make smoke-test
verify-test-upload: verify-test-sdist verify-test-bdist
verify-test-sdist:
@echo
@echo Testing source distribution from Test PyPI ...
@echo
make smoke-test PIP_OPTS="\
--no-binary :all: \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple cloudmarker"
verify-test-bdist:
@echo
@echo Testing wheel distribution from Test PyPI ...
@echo
make smoke-test PIP_OPTS="\
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple cloudmarker"
smoke-test: rmuservenv uservenv
. ./uservenv && pip3 install -U pip
. ./uservenv && pip3 install $(PIP_OPTS) cloudmarker
. ./uservenv && cd /tmp && python3 -m cloudmarker --help
. ./uservenv && cd /tmp && cloudmarker --help
. ./uservenv && cd /tmp && cloudmarker --config --now
. ./uservenv && cd /tmp && cloudmarker --version
clean: FORCE
find . -name "__pycache__" -exec rm -r {} +
find . -name "*.pyc" -exec rm {} +
rm -rf .coverage.* .coverage htmlcov build cloudmarker.egg-info dist
FORCE: