Add Python 3 runtime option to fail on implicit text/bytes conversion.
[dput.git] / Makefile
blob118a419fbeeeceae8592d08884cfb123f28b42db
1 #! /usr/bin/make -f
3 # Copyright © 2015–2016 Ben Finney <ben+python@benfinney.id.au>
5 # This is free software: you may copy, modify, and/or distribute this work
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; version 3 of that license or any later version.
8 # No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.
10 # Makefile for ‘dput’ code base.
12 PYTHON ?= /usr/bin/python2
13 PYTHON_OPTS ?= -3 -tt -bb
15 UNITTEST2 = /usr/bin/unit2
17 PY_MODULE_SUFFIX = .py
18 PY_MODULE_BYTECODE_SUFFIX = .pyc
19 package_modules = $(shell find ${CURDIR}/dput/ -name '*${PY_MODULE_SUFFIX}')
20 python_modules = $(shell find ${CURDIR}/ -name '*${PY_MODULE_SUFFIX}')
22 GENERATED_FILES :=
23 GENERATED_FILES += $(patsubst \
24 %${PY_MODULE_SUFFIX},%${PY_MODULE_BYTECODE_SUFFIX}, \
25 ${python_modules})
26 GENERATED_FILES += ${CURDIR}/*.egg-info
27 GENERATED_FILES += ${CURDIR}/build ${CURDIR}/dist
29 UNITTEST_OPTS ?= --buffer
31 PYTHON_COVERAGE = $(PYTHON) -m coverage
32 COVERAGE_RUN_OPTS ?= --branch
33 COVERAGE_REPORT_OPTS ?=
34 COVERAGE_TEXT_REPORT_OPTS ?=
35 COVERAGE_HTML_REPORT_OPTS ?=
38 .PHONY: all
39 all:
42 .PHONY: clean
43 clean:
44 $(RM) -r ${GENERATED_FILES}
47 .PHONY: tags
48 tags: TAGS
50 GENERATED_FILES += TAGS
52 TAGS: ${python_modules}
53 etags --output "$@" --lang=python ${python_modules}
56 .PHONY: test
57 test: test-unittest
59 .PHONY: test-unittest
60 test-unittest:
61 $(PYTHON) -m unittest discover ${UNITTEST_OPTS}
63 .PHONY: test-coverage
64 test-coverage: test-coverage-run test-coverage-html test-coverage-report
66 GENERATED_FILES += .coverage
68 .PHONY: test-coverage-run
69 test-coverage-run: coverage_opts = ${COVERAGE_RUN_OPTS}
70 test-coverage-run:
71 $(PYTHON) -m coverage run ${coverage_opts} \
72 $(UNITTEST2) discover ${UNITTEST_OPTS}
74 GENERATED_FILES += htmlcov/
76 .PHONY: test-coverage-html
77 test-coverage-html: coverage_opts = ${COVERAGE_REPORT_OPTS} ${COVERAGE_HTML_REPORT_OPTS}
78 test-coverage-html:
79 $(PYTHON_COVERAGE) html ${coverage_opts} ${package_modules}
81 .PHONY: test-coverage-report
82 test-coverage-report: coverage_opts = ${COVERAGE_REPORT_OPTS} ${COVERAGE_TEXT_REPORT_OPTS}
83 test-coverage-report:
84 $(PYTHON_COVERAGE) report ${coverage_opts} ${package_modules}
87 # Local variables:
88 # coding: utf-8
89 # mode: make
90 # End:
91 # vim: fileencoding=utf-8 filetype=make :