-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
100 lines (74 loc) · 2.21 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
# -*- mode: makefile; -*-
# Inspired by https://tech.davis-hansson.com/p/make/
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-print-directory
# Note MacOS ships with BSD Make 3.81, so need to install GNU Make 4.x via homebrew (brew install make)
# and place the gnubin on $PATH.
# We could probably get away with not using RECIPEPREFIX, but will do so for now since internal
# Equium standard
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
POETRY := poetry
poetry.lock: pyproject.toml
# If it is a new package, help by generating a lock file,
# but otherwise don't re-run poetry lock automatically as it will upgrade
# packages
> test -f poetry.lock || $(POETRY) lock
# In case poetry.lock existed before pyproject.toml, update the target
> touch -c poetry.lock
.venv: poetry.lock poetry.toml
> $(POETRY) install --extras "yaml"
# In case .venv existed before poetry.lock, update the target
> touch -c .venv
init: .venv
.PHONY: init
clean:
> rm -rf .venv *.egg-info pip-wheel-metadata .mypy_cache .coverage build dist
> find . -name "*.pyc" -type f -delete
> find . -type d -empty -delete
> find docs/_build ! -name .gitignore -delete
.PHONY: init
CHECK_ONLY ?=
ifdef CHECK_ONLY
ISORT_ARGS=--check-only -q
BLACK_ARGS=--check -q
else
ISORT_ARGS=
BLACK_ARGS=
endif
format: .venv
> $(POETRY) run isort --virtual-env .venv $(ISORT_ARGS) .
> $(POETRY) run black $(BLACK_ARGS) .
.PHONY: format
lint: .venv
> $(POETRY) run flake8 .
> CHECK_ONLY=true $(MAKE) format
# FIXME add mypy to lint (few failures make GH Actions)
# > $(MAKE) mypy
.PHONY: lint
mypy: .venv
> $(POETRY) run mypy --namespace-packages -p mazel
.PHONY: mypy
test: .venv
> $(POETRY) run python -m unittest discover -t . -s tests
.PHONY: test
SPHINX_BUILD_OPTIONS := docs docs/_build
docs: .venv
> $(POETRY) run sphinx-build -M html $(SPHINX_BUILD_OPTIONS)
.PHONY: docs
docs-serve: .venv
> $(POETRY) run sphinx-autobuild $(SPHINX_BUILD_OPTIONS)
.PHONY: docs
build:
> $(POETRY) build
.PHONY: build
publish: build
> $(POETRY) publish
.PHONY: publish