Skip to content

Commit

Permalink
Merge branch 'release/2019.1020'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Oct 20, 2019
2 parents e9faf24 + 3c9ec0e commit 89dfda2
Show file tree
Hide file tree
Showing 26 changed files with 133 additions and 262 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
bin/
venv/
.git/
.buildozer/
.pytest_cache/
.tox/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ bin/
build/
dist/
*.egg-info/
htmlcov/
.coverage
.coverage.*
15 changes: 3 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@ language: generic

services:
- docker
- xvfb

env:
global:
- DISPLAY=:99.0
matrix:
- TAG=zbarcam-linux DOCKERFILE=dockerfiles/Dockerfile-linux COMMAND='make test'
- TAG=zbarcam-linux DOCKERFILE=dockerfiles/Dockerfile-linux COMMAND='make uitest'
- TAG=zbarcam-android DOCKERFILE=dockerfiles/Dockerfile-android COMMAND='buildozer android debug'

before_install:
- sudo apt update -qq > /dev/null
- sudo apt install --yes --no-install-recommends xvfb

install:
- docker build --tag=$TAG --file=$DOCKERFILE --build-arg CI .

before_script:
- sh -e /etc/init.d/xvfb start
- docker build --tag=$TAG --file=$DOCKERFILE --build-arg CI .

script:
- travis_wait docker run -e DISPLAY -e CI -v /tmp/.X11-unix:/tmp/.X11-unix $TAG $COMMAND
- travis_wait 30 docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix $TAG $COMMAND
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [2019.1020]

- Setup coverage testing
- Bump to `xcamera>=2019.928`
- Continuous integration improvements

## [2019.0910]

- Use new `xcamera` from PyPI
Expand Down
82 changes: 54 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,69 @@
VENV_NAME=venv
PIP=$(VENV_NAME)/bin/pip
VIRTUAL_ENV ?= venv
PIP=$(VIRTUAL_ENV)/bin/pip
TOX=`which tox`
GARDEN=$(VENV_NAME)/bin/garden
PYTHON=$(VENV_NAME)/bin/python
ISORT=$(VENV_NAME)/bin/isort
FLAKE8=$(VENV_NAME)/bin/flake8
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= \
libpython$(PYTHON_VERSION)-dev \
build-essential \
ccache \
cmake \
curl \
git \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libpython3.6-dev \
libpython$(PYTHON_VERSION)-dev \
libzbar-dev \
pkg-config \
python3.6 \
python3.6-dev \
python$(PYTHON_VERSION) \
python$(PYTHON_VERSION)-dev \
tox \
virtualenv
OS=$(shell lsb_release -si)
OS=$(shell lsb_release -si 2>/dev/null || uname)
PYTHON_MAJOR_VERSION=3
PYTHON_MINOR_VERSION=6
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

venv:
test -d venv || virtualenv -p $(PYTHON_WITH_VERSION) venv
system_dependencies:
ifeq ($(OS), Ubuntu)
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
endif

virtualenv: venv
$(VIRTUAL_ENV):
virtualenv -p $(PYTHON_WITH_VERSION) $(VIRTUAL_ENV)
$(PIP) install Cython==0.28.6
$(PIP) install -r requirements/requirements.txt
$(PIP) install -r requirements.txt

virtualenv: $(VIRTUAL_ENV)

virtualenv/test: virtualenv
$(PIP) install -r requirements/requirements-test.txt

system_dependencies:
ifeq ($(OS), Ubuntu)
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
endif

run/linux: virtualenv
run: virtualenv
$(PYTHON) src/main.py

run: run/linux

test:
$(TOX)
@if test -n "$$CI"; then .tox/py$(PYTHON_MAJOR_MINOR)/bin/coveralls; fi; \

uitest: virtualenv/test
PYTHONPATH=src $(PYTHON) -m unittest discover --top-level-directory=. --start-directory=tests/ui/
pytest: virtualenv/test
PYTHONPATH=src $(PYTEST) --cov src/ --cov-report html tests/

lint/isort-check: virtualenv/test
$(ISORT) --check-only --recursive --diff $(SOURCES)
Expand All @@ -65,7 +79,7 @@ lint: lint/isort-check lint/flake8
docs/clean:
rm -rf $(DOCS_DIR)/build/

docs:
docs: virtualenv
cd $(DOCS_DIR) && SPHINXBUILD=$(SPHINXBUILD) make html

release/clean:
Expand All @@ -80,9 +94,21 @@ release/upload:
$(TWINE) upload dist/*

clean: release/clean docs/clean
py3clean src/
find src/ -type d -name "__pycache__" -exec rm -r {} +
find src/ -type d -name "*.egg-info" -exec rm -r {} +
py3clean .
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type d -name "*.egg-info" -exec rm -r {} +

clean/all: clean
rm -rf $(VENV_NAME) .tox/
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# zbarcam

[![Build Status](https://travis-ci.org/kivy-garden/zbarcam.svg?branch=develop)](https://travis-ci.org/kivy-garden/zbarcam)
[![Coverage Status](https://coveralls.io/repos/github/kivy-garden/zbarcam/badge.svg?branch=develop)](https://coveralls.io/github/kivy-garden/zbarcam?branch=develop)
[![PyPI version](https://badge.fury.io/py/zbarcam.svg)](https://badge.fury.io/py/zbarcam)
[![Documentation Status](https://readthedocs.org/projects/zbarcam/badge/?version=latest)](https://zbarcam.readthedocs.io/en/latest/?badge=latest)

Expand Down Expand Up @@ -37,7 +38,7 @@ make system_dependencies

Install zbarcam:
```sh
pip install --upgrade zbarcam
pip install zbarcam
```
Then import it in your Python code via:
```python
Expand Down
2 changes: 1 addition & 1 deletion buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ requirements =
Pillow==5.2.0,
python3,
pyzbar==0.1.8,
xcamera
xcamera==2019.928
# (str) Custom source folders for requirements
Expand Down
22 changes: 10 additions & 12 deletions dockerfiles/Dockerfile-android
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ENV WORK_DIR="${HOME_DIR}" \
ENV DOCKERFILES_VERSION="v20190902" \
DOCKERFILES_URL="https://raw.githubusercontent.com/AndreMiras/dockerfiles"
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android"
ENV BUILDOZER_VERSION="182d13f"
ENV BUILDOZER_VERSION="81c31c4"


# configure locale
Expand All @@ -29,7 +29,7 @@ ENV LANG="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"

# install system dependencies
RUN apt install -qq --yes --no-install-recommends \
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
autoconf \
automake \
ca-certificates \
Expand All @@ -54,20 +54,18 @@ RUN apt install -qq --yes --no-install-recommends \
xz-utils \
zip

# prepare non root env
RUN useradd --create-home --shell /bin/bash ${USER}
# with sudo access and no password
RUN usermod -append --groups sudo ${USER}
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# prepare non root env, with sudo access and no password
RUN useradd --create-home --shell /bin/bash ${USER} && \
usermod -append --groups sudo ${USER} && \
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER ${USER}
WORKDIR ${WORK_DIR}

# install buildozer and dependencies
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk
RUN make -f buildozer.mk
# enforces buildozer master until next release
RUN pip3 install --upgrade https://github.com/kivy/buildozer/archive/${BUILDOZER_VERSION}.zip
# install buildozer & dependencies and enforces buildozer master until next release
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk && \
make -f buildozer.mk && \
pip3 install --upgrade https://github.com/kivy/buildozer/archive/${BUILDOZER_VERSION}.zip

COPY . ${WORK_DIR}
# limits the amount of logs for Travis
Expand Down
24 changes: 4 additions & 20 deletions dockerfiles/Dockerfile-linux
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,21 @@ ENV LANG="en_US.UTF-8" \

# install system dependencies
RUN apt install --yes --no-install-recommends \
build-essential \
ccache \
cmake \
curl \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libpython3.6-dev \
libpython3.7-dev \
libzbar-dev \
lsb-release \
make \
pkg-config \
python3.6 \
python3.6-dev \
python3.7 \
python3.7-dev \
sudo \
tox \
virtualenv
sudo

# prepare non root env
RUN useradd --create-home --shell /bin/bash ${USER}
# with sudo access and no password
RUN usermod -append --groups sudo ${USER}
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# gives access to video so the camera can be accessed within the container
RUN gpasswd --add ${USER} video

USER ${USER}
WORKDIR ${WORK_DIR}
COPY . ${WORK_DIR}

RUN make
RUN sudo make system_dependencies && make virtualenv
ENTRYPOINT ["./dockerfiles/start.sh"]
9 changes: 9 additions & 0 deletions dockerfiles/env.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# used by coveralls.io, refs:
# https://coveralls-python.readthedocs.io/en/latest/usage/tox.html#travisci
CI
TRAVIS
TRAVIS_BRANCH
TRAVIS_JOB_ID
TRAVIS_PULL_REQUEST
# used for running UI tests
DISPLAY
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r requirements/requirements.txt
-r requirements/requirements-base.txt
-r requirements/requirements-documentation.txt
-r requirements/test_requirements.txt
-r requirements/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ numpy==1.16.1
opencv-python==4.1.1.26
Pillow==5.2.0
pyzbar==0.1.8
xcamera
xcamera==2019.928
2 changes: 2 additions & 0 deletions requirements/requirements-documentation.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
m2r==0.2.1
Sphinx
sphinx-rtd-theme
9 changes: 5 additions & 4 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
isort==4.2.5
flake8==3.3.0
mock==2.0.0
pytest==4.3.0
coveralls
flake8
isort
pytest
pytest-cov
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def read(fname):
'opencv-python>=4',
'pillow',
'pyzbar',
'xcamera',
'xcamera>=2019.928',
],
}

Expand Down
1 change: 0 additions & 1 deletion src/kivy_garden/zbarcam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""
import os


project_dir = os.path.abspath(
os.path.join(__file__, os.pardir, os.pardir, os.pardir, os.pardir))
using_pip = os.path.basename(project_dir).startswith('pip-')
Expand Down
23 changes: 0 additions & 23 deletions src/kivy_garden/zbarcam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,6 @@ def is_ios():
return platform == 'ios'


def check_camera_permission():
"""
Android runtime `CAMERA` permission check.
"""
if not is_android():
return True
from android.permissions import Permission, check_permission
permission = Permission.CAMERA
return check_permission(permission)


def check_request_camera_permission(callback=None):
"""
Android runtime `CAMERA` permission check & request.
"""
had_permission = check_camera_permission()
if not had_permission:
from android.permissions import Permission, request_permissions
permissions = [Permission.CAMERA]
request_permissions(permissions, callback)
return had_permission


def fix_android_image(pil_image):
"""
On Android, the image seems mirrored and rotated somehow, refs #32.
Expand Down
6 changes: 3 additions & 3 deletions src/kivy_garden/zbarcam/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__version__ = '2019.0910'
__version__ = '2019.1020'
# The `__version_code__` is used for the F-Droid auto update and should match
# the `versionCode` from the `build.gradle` file located in:
# `.buildozer/android/platform/build/dists/zbarcamdemo/`
# `.buildozer/android/platform/build-*/dists/zbarcamdemo__*/build.gradle`
# The auto update method used is the `HTTP`, see:
# https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
__version_code__ = 721202810
__version_code__ = 721202920
Loading

0 comments on commit 89dfda2

Please sign in to comment.