-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (40 loc) · 1.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
.DEFAULT_GOAL = all
VERSION = $(shell python3 setup.py --version 2>/dev/null)
WHEEL = dist/sm_aicli-$(VERSION)-py3-none-any.whl
PY = $(shell find setup.py python -name '*\.py' -or -name 'aicli' | grep -v semver.py | grep -v revision.py)
TEST = sh/runtests.sh
.PHONY: help # Print help
help:
@echo Build targets:
@cat Makefile | sed -n 's@^.PHONY: \([a-z]\+\) # \(.*\)@ \1: \2@p' | column -t -l2
$(WHEEL): $(PY) Makefile .stamp_readme
test -n "$(VERSION)"
rm -rf build dist || true
python3 setup.py sdist bdist_wheel
test -f $@
.PHONY: wheel # Build Python wheel (the DEFAULT target)
wheel: $(WHEEL)
.PHONY: version # Print the version
version:
@echo $(VERSION)
.stamp_readme: $(PY)
cp README.md _README.md.in
cat _README.md.in | litrepl \
--foreground --exception-exitcode=100 --sh-interpreter=- \
eval-sections >README.md
touch $@
.PHONY: test # Run tests
test: .stamp_test
.stamp_test: $(PY) $(TEST) Makefile
$(TEST)
touch $@
.PHONY: readme # Update code sections in the README.md
readme: .stamp_readme
.PHONY: upload # Upload wheel to Pypi.org (./_token.pypi is required)
upload: $(WHEEL)
twine upload \
--username __token__ \
--password $(shell cat _token.pypi) \
dist/*
.PHONY: all
all: wheel