-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (46 loc) · 2.01 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
PY_PACKAGE:=hetrixtools_blacklist_api
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
ROOT_NAME:=$(shell basename ${ROOT_DIR})
PARENT_DIR:=$(shell dirname ${ROOT_DIR})
TEST_FILES:=$(shell find ./tests/ -iname "*Test.py" | tr '\n' ',' | sed -e 's/,$$//g')
SPHINXOPTS?=
SPHINXBUILD?=sphinx-build
SOURCEDIR=source
BUILDDIR=build
PYTHON=python
TWINE=twine
all: run
run:
test: tests coverage
coverage:
nosetests --with-coverage --cover-package="${PY_PACKAGE}" --cover-html --cover-html-dir="reports" --tests "${TEST_FILES}"
tests:
nosetests --with-xunit --xunit-file="nosetests.xml" --tests "${TEST_FILES}"
syntax-check-python:
@python -m py_compile $(shell find ./ -not \( -path ./tests -prune \) -iname "*.py" ! -iname "__init__.py" -type f)
syntax-check: syntax-check-python
valid-full-coverage: ; $(eval PERCENT_COVERAGE=$(shell nosetests --with-coverage --cover-package="${PY_PACKAGE}" --cover-html --cover-html-dir="reports" --tests "${TEST_FILES}" 2>&1 | grep -E "^TOTAL" | awk '{ print $$4 }'))
@if [ "$(PERCENT_COVERAGE)" != "100%" ]; then false; fi
compile:
## To use it : make target=<TARGET> deploy
$(PYTHON) setup.py sdist
$(PYTHON) setup.py bdist_wheel
$(TWINE) check dist/*
$(TWINE) upload -r $(target) dist/*
.PHONY: docs
docs:
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
mkdir -p $(ROOT_DIR)/docs/
@cp -rv $(ROOT_DIR)/$(BUILDDIR)/html/* $(ROOT_DIR)/docs/
deploy: compile clean
auto-clean: clean
clean:
@echo ">> Remove python compilation : *.pyc / pycache / build / dist / egg"
@find . -iname "*.pyc" -exec rm {} \;
@find . -iname "\_\_pycache\_\_" -type d -exec rm -rf {} \; 2>/dev/null ; true
@find . -iname "*-info" -type d -exec rm -rf {} \; 2>/dev/null ; true
@find . -iname "build" -type d -exec rm -rf {} \; 2>/dev/null ; true
@find . -iname "dist" -type d -exec rm -rf {} \; 2>/dev/null ; true
@echo ">> Remove other compilation : java / nosetests / coverage"
@find . -iname "*.java" -exec rm {} \; 2>/dev/null ; true
@rm -rf reports/ nosetests.xml .coverage