-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
76 lines (58 loc) · 1.75 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
DESTDIR ?= /
UT ?=
SHELL = /usr/bin/env bash
PYTHON := $(shell which python3)
PACKAGE := $(shell $(PYTHON) setup.py --name | tr '-' '_')
VERSION := $(shell $(PYTHON) setup.py --version)
# List of files in the repository
TEST_FILES := $(wildcard test/test_*.py)
PKG_FILES := $(shell find $(PACKAGE) -type f -name '*.py')
REQ_FILES := $(wildcard requirements*.txt)
BIN_FILES := $(wildcard bin/*)
# Inferred targets from file names
LINT_TARGETS := setup.py $(PKG_FILES) $(BIN_FILES) $(shell find test -type f -name '*.py')
TEST_TARGETS := $(TEST_FILES:test/test_%.py=test_%)
EXT_TARGETS := $(wildcard ext/*)
.PHONY: \
$(EXT_TARGETS) \
$(REQ_FILES) \
$(TEST_TARGETS) \
clean \
ext \
format \
install \
lint \
requirements \
test
default:
clean:
@rm -rf .pytest_cache
@rm -rf .eggs
@rm -rf dist
@rm -rf build
@rm -rf $(PACKAGE).egg-info
requirements: $(REQ_FILES)
$(REQ_FILES):
@$(PYTHON) -m pip install --disable-pip-version-check -r $@
dist: dist/$(PACKAGE)-$(VERSION).tar.gz
dist/$(PACKAGE)-$(VERSION).tar.gz: $(PKG_FILES) setup.py
@$(PYTHON) -m pip install --disable-pip-version-check wheel
$(PYTHON) setup.py sdist bdist_wheel
upload: dist
@$(PYTHON) -m pip install --disable-pip-version-check wheel
$(PYTHON) -m twine upload dist/*$(VERSION)*
upload-test: dist
@$(PYTHON) -m pip install --disable-pip-version-check twine
$(PYTHON) -m twine upload --repository testpypi dist/*$(VERSION)*
format:
@black $(LINT_TARGETS)
lint:
@flake8 --filename='*' $(LINT_TARGETS)
type-check:
@mypy $(PACKAGE) test/ example.py
test:
@$(PYTHON) -m pytest --log-level=DEBUG -W default -v -s
$(TEST_TARGETS):
@$(PYTHON) -m pytest --log-cli-level=DEBUG -W default -v -s test/$(@).py $(if $(UT),-k $(UT),)
install:
$(PYTHON) setup.py install --root $(DESTDIR) --prefix .