| 1 |
# This file is part of CTDConverter, |
| 2 |
# https://github.com/WorkflowConversion/CTDConverter/, and is |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
# you may not use this file except in compliance with the License. |
| 6 |
# You may obtain a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
|
| 16 |
MODULE=ctdconverter |
| 17 |
|
| 18 |
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like |
| 19 |
# `[[` conditional expressions. |
| 20 |
|
| 21 |
PYSOURCES=$(wildcard tests/*.py) setup.py $(shell find ${MODULE} -name "*.py") |
| 22 |
DEVPKGS=diff_cover black pylint coverage pep257 pydocstyle flake8 mypy\ |
| 23 |
pytest-xdist isort wheel autoflake |
| 24 |
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount \ |
| 25 |
python-flake8 python-mock shellcheck |
| 26 |
VERSION=$(shell grep __version__ ctdconverter/__init__.py | awk '{ print $3 }') |
| 27 |
|
| 28 |
## all : default task |
| 29 |
all: install |
| 30 |
|
| 31 |
## help : print this help message and exit |
| 32 |
help: Makefile |
| 33 |
@sed -n 's/^##//p' $< | sed 's/$${MODULE}/${MODULE}/g' |
| 34 |
|
| 35 |
## install-dep : install most of the development dependencies via pip |
| 36 |
install-dep: install-dependencies |
| 37 |
|
| 38 |
install-dependencies: |
| 39 |
pip install --upgrade $(DEVPKGS) |
| 40 |
#pip install -r requirements.txt |
| 41 |
|
| 42 |
## install-deb-dep: install most of the dev dependencies via apt-get |
| 43 |
install-deb-dep: |
| 44 |
sudo apt-get install $(DEBDEVPKGS) |
| 45 |
|
| 46 |
## install : install the ${MODULE} module and any scripts |
| 47 |
install: FORCE |
| 48 |
pip install . |
| 49 |
|
| 50 |
## dev : install the ${MODULE} module in dev mode |
| 51 |
dev: install-dep |
| 52 |
pip install -e . |
| 53 |
|
| 54 |
|
| 55 |
## dist : create a module package for distribution |
| 56 |
dist: dist/${MODULE}-$(VERSION).tar.gz |
| 57 |
|
| 58 |
dist/${MODULE}-$(VERSION).tar.gz: $(SOURCES) |
| 59 |
./setup.py sdist bdist_wheel |
| 60 |
|
| 61 |
# ## docs : make the docs |
| 62 |
# docs: FORCE |
| 63 |
# cd docs && $(MAKE) html |
| 64 |
|
| 65 |
## clean : clean up all temporary / machine-generated files |
| 66 |
clean: FORCE |
| 67 |
rm -f ${MODULE}/*.pyc tests/*.pyc |
| 68 |
./setup.py clean --all || true |
| 69 |
rm -Rf .coverage |
| 70 |
rm -f diff-cover.html |
| 71 |
|
| 72 |
# Linting and code style related targets |
| 73 |
## isort: sort inputs using https://github.com/timothycrosley/isort |
| 74 |
sort_imports: |
| 75 |
isort ${MODULE}/*.py tests/*.py setup.py |
| 76 |
|
| 77 |
remove_unused_imports: $(PYSOURCES) |
| 78 |
autoflake --in-place --remove-all-unused-imports $^ |
| 79 |
|
| 80 |
pep257: pydocstyle |
| 81 |
## pydocstyle : check Python code style |
| 82 |
pydocstyle: $(PYSOURCES) |
| 83 |
pydocstyle --add-ignore=D100,D101,D102,D103 $^ || true |
| 84 |
|
| 85 |
pydocstyle_report.txt: $(filter-out tests/%,${PYSOURCES}) |
| 86 |
pydocstyle setup.py $^ > $@ 2>&1 || true |
| 87 |
|
| 88 |
diff_pydocstyle_report: pydocstyle_report.txt |
| 89 |
diff-quality --compare-branch=master --violations=pydocstyle --fail-under=100 $^ |
| 90 |
|
| 91 |
## format : check/fix all code indentation and formatting (runs black) |
| 92 |
format: $(PYSOURCES) |
| 93 |
black $^ |
| 94 |
|
| 95 |
## pylint : run static code analysis on Python code |
| 96 |
pylint: $(PYSOURCES) |
| 97 |
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \ |
| 98 |
$^ -j0|| true |
| 99 |
|
| 100 |
pylint_report.txt: ${PYSOURCES} |
| 101 |
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \ |
| 102 |
$^ -j0> $@ || true |
| 103 |
|
| 104 |
diff_pylint_report: pylint_report.txt |
| 105 |
diff-quality --violations=pylint pylint_report.txt |
| 106 |
|
| 107 |
.coverage: testcov |
| 108 |
|
| 109 |
coverage: .coverage |
| 110 |
coverage report |
| 111 |
|
| 112 |
coverage.xml: .coverage |
| 113 |
coverage xml |
| 114 |
|
| 115 |
coverage.html: htmlcov/index.html |
| 116 |
|
| 117 |
htmlcov/index.html: .coverage |
| 118 |
coverage html |
| 119 |
@echo Test coverage of the Python code is now in htmlcov/index.html |
| 120 |
|
| 121 |
coverage-report: .coverage |
| 122 |
coverage report |
| 123 |
|
| 124 |
diff-cover: coverage.xml |
| 125 |
diff-cover $^ |
| 126 |
|
| 127 |
diff-cover.html: coverage.xml |
| 128 |
diff-cover $^ --html-report $@ |
| 129 |
|
| 130 |
## test : run the ${MODULE} test suite |
| 131 |
test: $(pysources) |
| 132 |
python setup.py test |
| 133 |
|
| 134 |
## testcov : run the ${MODULE} test suite and collect coverage |
| 135 |
testcov: $(pysources) |
| 136 |
python setup.py test --addopts "--cov ${MODULE} -n auto --dist=loadfile" |
| 137 |
|
| 138 |
sloccount.sc: ${PYSOURCES} Makefile |
| 139 |
sloccount --duplicates --wide --details $^ > $@ |
| 140 |
|
| 141 |
## sloccount : count lines of code |
| 142 |
sloccount: ${PYSOURCES} Makefile |
| 143 |
sloccount $^ |
| 144 |
|
| 145 |
list-author-emails: |
| 146 |
@echo 'name, E-Mail Address' |
| 147 |
@git log --format='%aN,%aE' | sort -u | grep -v 'root' |
| 148 |
|
| 149 |
mypy: $(filter-out setup.py,${PYSOURCES}) |
| 150 |
mypy --disallow-untyped-calls \ |
| 151 |
--warn-redundant-casts \ |
| 152 |
$^ |
| 153 |
|
| 154 |
shellcheck: create-galaxy-tests.sh |
| 155 |
shellcheck $^ |
| 156 |
|
| 157 |
FORCE: |
| 158 |
|
| 159 |
# Use this to print the value of a Makefile variable |
| 160 |
# Example `make print-VERSION` |
| 161 |
# From https://www.cmcrossroads.com/article/printing-value-makefile-variable |
| 162 |
print-% : ; @echo $* = $($*) |