-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (115 loc) · 3.83 KB
/
Makefile
File metadata and controls
132 lines (115 loc) · 3.83 KB
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
SHELL := /bin/bash
PYTHON := $(shell which python)
.PHONY: help
help:
@echo "using python at $(PYTHON)."
@$(PYTHON) --version
@echo "usage: make <target>"
@echo
@echo "target is one of:"
@echo " help show this message and exit"
@echo " build build the python package and wheels"
@echo " clean remove temporary files"
@echo " cov run coverage check"
@echo " cov-html generate html coverage report"
@echo " dev setup local dev environment by installing required packages, etc."
@echo " dev-env create a python virtual environment in ./mots-env"
@echo " docs generate documentation"
@echo " publish-test publish package to test.pypi.org"
@echo " publish publish package to pypi.org"
@echo " requirements regenerate requirements.txt"
@echo " serve-cov simple http server for coverage report"
@echo " serve-docs simple http server for docs"
@echo " test run the test suite"
.PHONY: test
test:
$(PYTHON) -m pytest -vvv
.PHONY: build
build:
$(PYTHON) -m build
.PHONY: docs
docs:
make -C documentation html
.PHONY: cov
cov:
-@rm -R .coverage 2>/dev/null ||:
$(PYTHON) -m pytest --cov-fail-under=50 --cov=src/mots tests
.PHONY: cov-html
cov-html:
-@rm -R .coverage 2>/dev/null ||:
-@rm -R .htmlcov 2>/dev/null ||:
$(PYTHON) -m pytest --cov=src/mots tests --cov-report html
.PHONY: serve-cov
serve-cov:
$(PYTHON) -m http.server -d htmlcov 8080
.PHONY: format
format:
$(PYTHON) -m black src/mots
$(PYTHON) -m black tests
$(PYTHON) -m black documentation
.ONESHELL:
.PHONY: publish
publish:
ifdef PYPI_TOKEN
$(PYTHON) -m twine upload -r pypi dist/* --verbose \
--username __token__ --password $(PYPI_TOKEN)
else
$(error "PYPI_TOKEN must be defined.")
endif
.ONESHELL:
.PHONY: publish-test
publish-test:
ifdef TESTPYPI_TOKEN
$(PYTHON) -m twine upload -r testpypi dist/* --verbose \
--username __token__ --password $(TESTPYPI_TOKEN)
else
$(error "TESTPYPI_TOKEN must be defined.")
endif
.PHONY: requirements
requirements:
rm requirements/*.txt
docker-compose run generate-python3.8-requirements
docker-compose run generate-python3.9-requirements
docker-compose run generate-python3.10-requirements
docker-compose run generate-python3.11-requirements
docker-compose run generate-python3.12-requirements
docker-compose run generate-python3.13-requirements
.ONESHELL:
.PHONY: dev-env
dev-env:
ifdef PY
@echo "Creating virtual env in .mots-env using provided Python ($(PY))..."
-@(/usr/bin/$(PY) -m venv .mots-env && ([ $$? -eq 0 ] && echo "$(PY) found.")) 2>/dev/null||
-@(/usr/local/bin/$(PY) -m venv .mots-env && ([ $$? -eq 0 ] && echo "$(PY) found.")) 2>/dev/null
else
@echo "PY variable not defined, using python3 if available..."
@echo "Creating virtual env in .mots-env using python3..."
-@(python3 -m venv .mots-env && ([ $$? -eq 0 ] && echo "Found $(shell python3 --version)")) 2>/dev/null
endif
.ONESHELL:
.PHONY: dev
dev:
set -e
. ./.mots-env/bin/activate
python -m pip install --upgrade pip
python -m pip install pip-tools
python -m pip install -r requirements/$$(./requirements/get_filename)
python -m pip install -e .
.PHONY: serve-docs
serve-docs:
$(PYTHON) -m http.server -d documentation/_build/html 8080
.PHONY: clean
clean:
-@rm -R htmlcov 2>/dev/null ||:
-@rm -R documentation/_build 2>/dev/null ||:
-@rm -R dist 2>/dev/null ||:
-@rm -R src/*.egg-info 2>/dev/null ||:
-@rm -R src/mots/__pycache__ 2>/dev/null ||:
-@rm -R tests/__pycache__ 2>/dev/null ||:
-@rm -R .coverage 2>/dev/null ||:
-@rm -R .pytest_cache 2>/dev/null ||:
-@rm -R .mots-env 2>/dev/null ||:
-@rm -R .pytest_cache-env 2>/dev/null ||: