forked from upciti/wheel2deb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (48 loc) · 1.67 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
MAKE := $(MAKE) --no-print-directory
SHELL = sh
IMAGE_NAME ?= parkoview/wheel2deb
DEBIAN_DISTS := stretch buster
map = $(foreach a,$(2),$(call $(1),$(a)))
default:
@echo "Makefile for wheel2deb"
@echo
@echo 'Usage:'
@echo
@echo ' make check check coding style (PEP-8, PEP-257)'
@echo ' make bdist build python wheel'
@echo ' make images build docker images'
@echo ' make clean cleanup all temporary files'
@echo ' make tests run pytest in docker images'
@echo ' make publish push release to pypi'
@echo
bdist:
@rm -f dist/*.whl
@python3 setup.py bdist_wheel
images:
@cp docker/dh-autoreconf_* dist/
$(call map,build_debian_image,$(DEBIAN_DISTS))
check:
@flake8 src
tests: bdist
$(eval images := $(foreach a,$(DEBIAN_DISTS),$(IMAGE_NAME):$(a)))
$(call map,run_tests,$(images))
publish: clean bdist
twine upload dist/*.whl
clean:
@rm -Rf src/*.egg-info .pytest_cache .cache .coverage .tox build dist docs/build htmlcov
@find -depth -type d -name __pycache__ -exec rm -Rf {} \;
@find -type f -name '*.pyc' -delete
.PHONY: default bdist images clean publish check
define build_jessie_image
cat docker/Dockerfile.in | sed s/_IMAGE_/debian:jessie-patched/ | docker build -t $(IMAGE_NAME):jessie --cache-from $(IMAGE_NAME):jessie -f - dist;
endef
define build_debian_image
cat docker/Dockerfile.in | sed s/_IMAGE_/debian:$(1)-slim/ | docker build -t $(IMAGE_NAME):$(1) --cache-from $(IMAGE_NAME):$(1) -f - dist;
endef
define run_tests
docker run -v $(CURDIR):/data --entrypoint "" $(1) /bin/sh -c " \
pip install dist/*.whl \
&& rm -rf testing/__pycache__ \
&& py.test --cov"; \
if (test $$? -ne 0); then exit 1; fi;
endef