-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (92 loc) · 2.59 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
.DEFAULT_GOAL := help
.PHONY: test
test: ## Run tests with pytest and coverage
@echo "+ $@"
@echo "+ doctest"
python -m doctest rbStata/cli.py --verbose
@echo "+ pytest + coverage"
-mkdir temp
coverage erase
coverage run -m pytest -v
coverage report -m
@rm -rf temp
make clean-dta
# Git checkout census.dta
git checkout assets/datasets/census.dta
.PHONY: lint
MYPY_OPTS := --ignore-missing-imports
BLACK_OPTS := --line-length 80
lint: ## Check with mypy, pyflakes, black
@echo "+ $@"
@echo "+ pyflakes"
python -m pyflakes rbStata/*.py
python -m pyflakes tests/*.py
python -m pyflakes setup.py
@echo "+ Static typing"
mypy rbStata/*.py $(MYPY_OPTS)
@echo "+ docstrings"
pydocstyle --convention numpy
@echo "+ imports"
isort .
@echo "+ Black"
black setup.py $(BLACK_OPTS)
black rbStata/*.py $(BLACK_OPTS)
black tests/*.py $(BLACK_OPTS)
.PHONY: clean-dta
clean-dta: ## Remove unoriginal dta artifacts (e.g. auto-v13.dta)
@echo "+ $@"
@find . -type f -name '*_v*.dta' -exec rm -f {} +
@find . -type f -name '*_v.dta' -exec rm -f {} +
@find . -type f -name '*-*.dta' -exec rm -f {} +
@find . -type f -name '*test*.dta' -exec rm -f {} +
@find . -type f -name '*out*.dta' -exec rm -f {} +
.PHONY: clean-test
clean-test: ## Remove testing and coverage artifacts
@echo "+ $@"
@rm -rf .pytest_cache/
@rm -rf htmlcov/
@rm -rf .coverage
@rm -rf coverage.xml
.PHONY: clean-pyc
clean-pyc: ## Remove Python file artifacts
@echo "+ $@"
@find . -type d -name '__pycache__' -exec rm -rf {} +
@find . -type f -name '*.py[co]' -exec rm -f {} +
@find . -name '*~' -exec rm -f {} +
.PHONY: clean-mypy
clean-mypy: ## Remove mypy artifacts
@echo "+ $@"
@rm -rf .mypy_cache
.PHONY: clean-build
clean-build: ## Remove build artifacts
@echo "+ $@"
@rm -fr build/
@rm -fr dist/
@rm -fr *.egg-info
@rm -fr *.egg
.PHONY: clean-ipynb
clean-ipynb: ## Remove ipynb artifacts
@echo "+ $@"
@rm -fr *.ipynb_checkpoints
.PHONY: clean
clean: ## Remove artifacts
clean: clean-test clean-ipynb clean-mypy clean-pyc clean-build clean-dta
.PHONY: build
build: clean test lint ## Prepare packaging for PyPi
@echo "+ $@"
@rm -rf dist/ rbStata.egg-info/
@python setup.py sdist
twine check dist/*
.PHONY: setup
setup: ## Set up dependencies
@echo "+ $@"
@pip install -r tests/requirements_dev.txt
@pip install -r requirements.txt
.PHONY: devtest
devtest: ## Install dev and test in editable mode
@echo "+ $@"
pip install -e .
rbstata
.PHONY: help
help: ## Show this help message and exit
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'