Skip to content

Commit 8e12fbc

Browse files
authored
Merge pull request #22 from devilbox/python
Add Python Makefile
2 parents 7fb017b + 8ab02f2 commit 8e12fbc

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

Makefile.python

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
ifneq (,)
2+
.error This Makefile requires GNU Make.
3+
endif
4+
5+
ifndef VERBOSE
6+
MAKEFLAGS += --no-print-directory
7+
endif
8+
9+
10+
# -------------------------------------------------------------------------------------------------
11+
# Default configuration
12+
# -------------------------------------------------------------------------------------------------
13+
# MyPy
14+
MYPY_VERSION = latest
15+
MYPY_ARGS =
16+
MYPY_DIR = .
17+
18+
# Pylint
19+
PYLINT_VERSION = latest
20+
PYLINT_PIP_PKGS =
21+
PYLINT_ARGS =
22+
PYLINT_DIR = .
23+
24+
25+
# -------------------------------------------------------------------------------------------------
26+
# Lint Targets
27+
# -------------------------------------------------------------------------------------------------
28+
.PHONY: lint
29+
lint:: lint-mypy
30+
lint:: lint-pylint
31+
32+
33+
.PHONY: lint-mypy
34+
lint-mypy: _lint-mypy-pull
35+
lint-mypy:
36+
@echo "################################################################################"
37+
@echo "# Lint MyPy"
38+
@echo "################################################################################"
39+
docker run --rm $$(tty -s && echo "-it" || echo) -e PIP_ROOT_USER_ACTION=ignore -v $$(pwd):/data -w /data cytopia/mypy:$(MYPY_VERSION) \
40+
--install-types \
41+
--non-interactive \
42+
$(MYPY_ARGS) $(MYPY_DIR)
43+
44+
.PHONY: lint-pylint
45+
lint-pylint: _lint-pylint-pull
46+
lint-pylint:
47+
@echo "################################################################################"
48+
@echo "# Lint Pylint"
49+
@echo "################################################################################"
50+
docker run --rm $$(tty -s && echo "-it" || echo) -e PIP_ROOT_USER_ACTION=ignore -v $$(pwd):/data -w /data --entrypoint=sh cytopia/pylint:$(PYLINT_VERSION) \
51+
-c 'for pkg in $(PYLINT_PIP_PKGS); do python3 -m pip install $${pkg}; done && pylint $(PYLINT_ARGS) $(PYLINT_DIR)'
52+
53+
54+
# -------------------------------------------------------------------------------------------------
55+
# Helper Targets
56+
# -------------------------------------------------------------------------------------------------
57+
.PHONY: _lint-mypy-pull
58+
_lint-mypy-pull:
59+
@echo "Pulling cytopia/mypy:$(MYPY_VERSION)"; \
60+
SUCC=0; \
61+
for i in $$(seq 10); do \
62+
if docker pull -q cytopia/mypy:$(MYPY_VERSION); then \
63+
SUCC=1; \
64+
break; \
65+
fi; \
66+
sleep 1; \
67+
done; \
68+
if [ "$${SUCC}" = "0" ]; then echo "FAILED"; exit 1; fi;
69+
70+
.PHONY: _lint-pylint-pull
71+
_lint-pylint-pull:
72+
@echo "Pulling cytopia/pylint:$(PYLINT_VERSION)"; \
73+
SUCC=0; \
74+
for i in $$(seq 10); do \
75+
if docker pull -q cytopia/pylint:$(PYLINT_VERSION); then \
76+
SUCC=1; \
77+
break; \
78+
fi; \
79+
sleep 1; \
80+
done; \
81+
if [ "$${SUCC}" = "0" ]; then echo "FAILED"; exit 1; fi;

0 commit comments

Comments
 (0)