-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
153 lines (120 loc) · 4.27 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
VIRTUAL_ENV ?= venv
ACTIVATE_PATH=$(VIRTUAL_ENV)/bin/activate
PIP=$(VIRTUAL_ENV)/bin/pip
PYTHON_MAJOR_VERSION=3
PYTHON_MINOR_VERSION=8
PYTHON_VERSION=$(PYTHON_MAJOR_VERSION).$(PYTHON_MINOR_VERSION)
PYTHON_MAJOR_MINOR=$(PYTHON_MAJOR_VERSION)$(PYTHON_MINOR_VERSION)
PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
PYTHON=$(VIRTUAL_ENV)/bin/python
ISORT=$(VIRTUAL_ENV)/bin/isort
FLAKE8=$(VIRTUAL_ENV)/bin/flake8
PYTEST=$(VIRTUAL_ENV)/bin/pytest
COVERAGE=$(VIRTUAL_ENV)/bin/coverage
TWINE=`which twine`
SOURCES=src/
DOCKER_IMAGE_LINUX=andremiras/pywallet-linux
DOCKER_IMAGE_ANDROID=andremiras/pywallet-android
DOCKER_VOLUME=/tmp/.X11-unix:/tmp/.X11-unix
SYSTEM_DEPENDENCIES_BASE= \
libpython$(PYTHON_VERSION)-dev \
python$(PYTHON_VERSION)
SYSTEM_DEPENDENCIES_LINUX= \
build-essential \
libgl1 \
libzbar0 \
python$(PYTHON_MAJOR_VERSION)-virtualenv \
tox
SYSTEM_DEPENDENCIES_ANDROID= \
autoconf \
automake \
cmake \
gettext \
libffi-dev \
libltdl-dev \
git \
libssl-dev \
libtool \
openjdk-8-jdk-headless \
patch \
pkg-config \
python$(PYTHON_MAJOR_VERSION)-pip \
python$(PYTHON_MAJOR_VERSION)-setuptools \
unzip \
zlib1g-dev \
zip
ifndef CI
DOCKER_DEVICE=--device=/dev/video0:/dev/video0
DOCKER_IT=-it
endif
all: virtualenv
system_dependencies:
apt update -qq > /dev/null && sudo apt -qq install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_BASE)
system_dependencies/linux: system_dependencies
apt update -qq > /dev/null && sudo apt -qq install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_LINUX)
system_dependencies/android: system_dependencies
apt update -qq > /dev/null && sudo apt -qq install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_ANDROID)
$(VIRTUAL_ENV):
virtualenv --python $(PYTHON_WITH_VERSION) $(VIRTUAL_ENV)
$(PIP) install Cython==0.28.6
$(PIP) install -r requirements.txt
virtualenv: $(VIRTUAL_ENV)
run: virtualenv
$(PYTHON) src/main.py
pytest: virtualenv
$(COVERAGE) erase
$(COVERAGE) run -m unittest discover --start-directory=src/
$(COVERAGE) report
test: pytest lint
@if test -n "$$CI"; then make uitest; fi; \
uitest: virtualenv
. $(ACTIVATE_PATH) && \
$(PYTHON) -m kivyunittest --folder src/tests/ui/ --pythonpath src/
lint/isort-check: virtualenv
$(ISORT) --check-only --recursive --diff $(SOURCES)
lint/isort-fix: virtualenv
$(ISORT) --recursive $(SOURCES)
lint/flake8: virtualenv
$(FLAKE8) $(SOURCES)
lint/mypy: virtualenv
# $(MYPY) --ignore-missing-imports $(shell find src/pywallet/ -name "*.py")
lint: lint/isort-check lint/flake8 lint/mypy
release/clean:
rm -rf dist/ build/
release/build: release/clean clean
$(PYTHON) setup.py sdist bdist_wheel
$(TWINE) check dist/*
release/upload:
$(TWINE) upload dist/*
clean:
rm -rf .pytest_cache/
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type d -name "*.egg-info" -exec rm -r {} +
clean/venv: clean
rm -rf $(VIRTUAL_ENV)
buildozer/android/debug:
@if test -n "$$CI"; then sed 's/log_level = [0-9]/log_level = 1/' -i buildozer.spec; fi; \
buildozer android debug
docker/pull/linux:
docker pull $(DOCKER_IMAGE_LINUX):latest
docker/pull/android:
docker pull $(DOCKER_IMAGE_ANDROID):latest
docker/build/linux:
docker build --cache-from=$(DOCKER_IMAGE_LINUX) --tag=$(DOCKER_IMAGE_LINUX) --file=dockerfiles/Dockerfile-linux .
docker/build/android:
docker build --cache-from=$(DOCKER_IMAGE_ANDROID) --tag=$(DOCKER_IMAGE_ANDROID) --file=dockerfiles/Dockerfile-android .
docker/push/linux:
docker push $(DOCKER_IMAGE_LINUX)
docker/push/android:
docker push $(DOCKER_IMAGE_ANDROID)
docker/push: docker/push/linux docker/push/android
docker/run/test/linux:
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) $(DOCKER_IT) --rm $(DOCKER_IMAGE_LINUX) make test
docker/run/test/android:
docker run --env-file dockerfiles/env.list $(DOCKER_IMAGE_ANDROID) make buildozer/android/debug
docker/run/app:
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) -it --rm $(DOCKER_IMAGE_LINUX) make run
docker/run/shell/linux:
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) -it --rm $(DOCKER_IMAGE_LINUX)
docker/run/shell/android:
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) -it --rm $(DOCKER_IMAGE_ANDROID)