-
Notifications
You must be signed in to change notification settings - Fork 32
/
Makefile
113 lines (89 loc) · 2.79 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
VIRTUAL_ENV ?= venv
PIP=$(VIRTUAL_ENV)/bin/pip
TOX=`which tox`
PYTHON=$(VIRTUAL_ENV)/bin/python
ISORT=$(VIRTUAL_ENV)/bin/isort
FLAKE8=$(VIRTUAL_ENV)/bin/flake8
PYTEST=$(VIRTUAL_ENV)/bin/pytest
TWINE=`which twine`
SOURCES=src/ tests/ setup.py setup_meta.py
# using full path so it can be used outside the root dir
SPHINXBUILD=$(shell realpath venv/bin/sphinx-build)
DOCS_DIR=doc
SYSTEM_DEPENDENCIES= \
build-essential \
ccache \
cmake \
curl \
git \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libpython3.7-dev \
libpython$(PYTHON_VERSION)-dev \
libzbar-dev \
pkg-config \
python$(PYTHON_VERSION) \
python$(PYTHON_VERSION)-dev \
python$(PYTHON_VERSION)-venv \
tox \
virtualenv
OS=$(shell lsb_release -si 2>/dev/null || uname)
PYTHON_MAJOR_VERSION=3
PYTHON_MINOR_VERSION=7
PYTHON_VERSION=$(PYTHON_MAJOR_VERSION).$(PYTHON_MINOR_VERSION)
PYTHON_MAJOR_MINOR=$(PYTHON_MAJOR_VERSION)$(PYTHON_MINOR_VERSION)
PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
all: system_dependencies virtualenv
system_dependencies:
ifeq ($(OS), Ubuntu)
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
endif
$(VIRTUAL_ENV):
$(PYTHON_WITH_VERSION) -m venv $(VIRTUAL_ENV)
$(PIP) install Cython==0.28.6
$(PIP) install -r requirements.txt
virtualenv: $(VIRTUAL_ENV)
virtualenv/test: virtualenv
$(PIP) install -r requirements/requirements-test.txt
run: virtualenv
$(PYTHON) src/main.py
test:
$(TOX)
@if test -n "$$CI"; then .tox/py$(PYTHON_MAJOR_MINOR)/bin/coveralls; fi; \
pytest: virtualenv/test
PYTHONPATH=src $(PYTEST) --cov src/ --cov-report html tests/
lint/isort-check: virtualenv/test
$(ISORT) --check --diff $(SOURCES)
lint/isort-fix: virtualenv/test
$(ISORT) $(SOURCES)
lint/flake8: virtualenv/test
$(FLAKE8) $(SOURCES)
lint: lint/isort-check lint/flake8
docs/clean:
rm -rf $(DOCS_DIR)/build/
docs: virtualenv
cd $(DOCS_DIR) && SPHINXBUILD=$(SPHINXBUILD) make html
release/clean:
rm -rf dist/ build/
release/build: release/clean
$(PYTHON) setup.py sdist bdist_wheel
$(PYTHON) setup_meta.py sdist bdist_wheel
$(TWINE) check dist/*
release/upload:
$(TWINE) upload dist/*
clean: release/clean docs/clean
py3clean .
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type d -name "*.egg-info" -exec rm -r {} +
clean/all: clean
rm -rf $(VIRTUAL_ENV) .tox/
docker/build:
docker build --tag=zbarcam-linux --file=dockerfiles/Dockerfile-linux .
docker/run/test:
docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix zbarcam-linux 'make test'
docker/run/app:
docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix --device=/dev/video0:/dev/video0 zbarcam-linux 'make run'
docker/run/shell:
docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix --device=/dev/video0:/dev/video0 -it --rm zbarcam-linux