-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
148 lines (125 loc) · 5.49 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
MAIN=things
SRC_CORE=./things
SRC_TEST=tests
DST_DOCS=docs
PYTHON=python3
PYDOC=pydoc3
PIP=pip3
PIPENV=pipenv
PDOC=pdoc
DATE:=$(shell date +"%Y-%m-%d")
VERSION=$(shell $(PYTHON) -c 'import things; print(things.__version__)')
help: ## Print help for each target
$(info Things low-level Python API.)
$(info ============================)
$(info )
$(info Available commands:)
$(info )
@grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'
run: ## Run the code
@$(PYTHON) -m $(SRC_CORE).$(MAIN)
install: ## Install the code
@$(PYTHON) setup.py install
uninstall: ## Uninstall the code
@$(PIP) uninstall -y things
test: ## Test the code
@type coverage >/dev/null 2>&1 || (echo "Run '$(PIP) install coverage' first." >&2 ; exit 1)
@coverage erase
@coverage run -a -m $(SRC_TEST).test_things
@coverage report
@coverage html
testdoc: ## Test the code within the documentation
@coverage erase
@type pytest >/dev/null 2>&1 || (echo "Run '$(PIP) install pytest' first." >&2 ; exit 1)
THINGSDB=tests/main.sqlite pytest --cov=things -W ignore::UserWarning --cov-report=xml --cov-context=test --doctest-modules
@coverage report
@coverage html
.PHONY: doc
doc: install ## Document the code
@type pytest >/dev/null 2>&1 || (echo "Run '$(PIP) install pytest' first." >&2 ; exit 1)
@#$(PYDOC) $(SRC_CORE).api
@$(PDOC) -o $(DST_DOCS) -d numpy -n $(SRC_CORE)
@echo "Now open $(DST_DOCS)"
.PHONY: clean
clean: ## Cleanup
@rm -f $(DEST)
@find . -name \*.pyc -delete
@find . -name __pycache__ -delete
@rm -rf htmlcov
@rm -rf build dist *.egg-info .eggs
@rm -rf .mypy_cache/ */.mypy_cache/
@rm -f .coverage
@rm -rf .tox
@rm -rf .ruff_cache
auto-style: ## Style the code
@if type isort >/dev/null 2>&1 ; then isort . ; \
else echo "SKIPPED. Run '$(PIP) install isort' first." >&2 ; fi
@if type autoflake >/dev/null 2>&1 ; then autoflake -r --in-place --remove-unused-variables . ; \
else echo "SKIPPED. Run '$(PIP) install isort' first." >&2 ; fi
@if type black >/dev/null 2>&1 ; then black . ; \
else echo "SKIPPED. Run '$(PIP) install black' first." >&2 ; fi
code-style: ## Test the code style
@echo Pycodestyle...
@if type pycodestyle >/dev/null 2>&1 ; then pycodestyle *.py $(SRC_CORE)/*.py $(SRC_TEST)/*.py ; \
else echo "SKIPPED. Run '$(PIP) install pycodestyle' first." >&2 ; fi
@echo Pydocstyle...
@if type pydocstyle >/dev/null 2>&1 ; then pydocstyle $(SRC_CORE)/*.py $(SRC_TEST)/*.py ; \
else echo "SKIPPED. Run '$(PIP) install pydocstyle' first." >&2 ; fi
code-count: ## Count the code
@if type cloc >/dev/null 2>&1 ; then cloc $(SRC_CORE) ; \
else echo "SKIPPED. Run 'brew install cloc' first." >&2 ; fi
code-lint: code-style ## Lint the code
@echo Pylama...
@if type pylama >/dev/null 2>&1 ; then pylama *.py $(SRC_CORE)/*.py $(SRC_TEST)/*.py ; \
else echo "SKIPPED. Run '$(PIP) install pylama' first." >&2 ; fi
@echo Pylint...
@if type pylint >/dev/null 2>&1 ; then pylint -sn *.py $(SRC_CORE) $(SRC_TEST) ; \
else echo "SKIPPED. Run '$(PIP) install pylint' first." >&2 ; fi
@echo Ruff...
@if type ruff >/dev/null 2>&1 ; then ruff check . ; \
else echo "SKIPPED. Run '$(PIP) install ruff' first." >&2 ; fi
@echo Flake...
@if type flake8 >/dev/null 2>&1 ; then flake8 . ; \
else echo "SKIPPED. Run '$(PIP) install flake8' first." >&2 ; fi
code-check-types: ## Check the code types
@echo Pyright...
@if type pyright >/dev/null 2>&1 ; then PYRIGHT_PYTHON_FORCE_VERSION=latest pyright *.py $(SRC_CORE) $(SRC_TEST) ; \
else echo "SKIPPED. Run 'npm install -f pyright' first." >&2 ; fi
@echo MyPy...
@if type mypy >/dev/null 2>&1 ; then mypy --check-untyped-defs --no-error-summary --ignore-missing-imports *.py $(SRC_CORE) $(SRC_TEST) ; \
else echo "SKIPPED. Run '$(PIP) install mypy' first." >&2 ; fi
@echo Vulture...
@if type vulture >/dev/null 2>&1 ; then vulture *.py $(SRC_CORE)/*.py $(SRC_TEST)/*.py --exclude conftest.py; \
else echo "SKIPPED. Run '$(PIP) install vulture' first." >&2 ; fi
lint: code-style code-lint ## Lint everything
deps-install: ## Install the dependencies
@type $(PIPENV) >/dev/null 2>&1 || (echo "Run e.g. 'brew install pipenv' first." >&2 ; exit 1)
@$(PIPENV) install --dev
npm install pyright
feedback: ## Give feedback
@open https://github.com/thingsapi/things.py/issues
release: build ## Create a new release
@type gh >/dev/null 2>&1 || (echo "Run e.g. 'brew install gh' first." >&2 ; exit 1)
@echo "Checking for not committed changes..."
@git diff --exit-code && git diff --cached --exit-code
@echo "########################"
@echo Making release for version "$(VERSION)". Press ENTER to continue...
@echo "########################"
@read
@gh release create "v$(VERSION)" -t "Release $(VERSION) ($(DATE))" 'dist/$(MAIN).py-$(VERSION).tar.gz'
build: clean ## Build the code
@$(PYTHON) setup.py sdist bdist_wheel
upload: build ## Upload the code
@type twine >/dev/null 2>&1 || (echo "Run e.g. 'pip install twine' first." >&2 ; exit 1)
@echo "########################"
@echo "Using ~/.pypirc or environment variables TWINE_USERNAME and TWINE_PASSWORD"
@echo "See: https://packaging.python.org/specifications/pypirc/#using-a-pypi-token"
@echo "########################"
@twine upload dist/things.py*
db-to-things:
@cp tests/main.sqlite* ~/Library/Group\ Containers/JLMPQHK86H.com.culturedcode.ThingsMac/ThingsData-*/Things\ Database.thingsdatabase/
db-from-things:
@cp ~/Library/Group\ Containers/JLMPQHK86H.com.culturedcode.ThingsMac/ThingsData-*/Things\ Database.thingsdatabase/main.sqlite* tests
info:
pipenv --venv