Skip to content

Commit eb648c5

Browse files
committed
Merge branch 'release/20190902'
2 parents ddafb79 + 82e2e63 commit eb648c5

35 files changed

+553
-93
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ venv/
44
.buildozer/
55
.pytest_cache/
66
.tox/
7-
opencv*
7+
opencv-*

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ venv/
55
.tox/
66
.buildozer/
77
bin/
8+
opencv-*
9+
build/
10+
dist/
11+
*.egg-info/

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## [20190902]
4+
5+
- Update Cython for Python3.7 support, refs #35
6+
- Make garden.zbarcam a package again, refs #36
7+
- Don't ship opencv directory to APK, refs #37
8+
- Migrate to new garden structure, refs #17
9+
- Publish documentation to readthedocs, refs #18
10+
- Publish to PyPI, refs #19
11+
312
## [20190303]
413

514
- Add Python3.6 support, refs #5

Makefile

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ PIP=$(VENV_NAME)/bin/pip
33
TOX=`which tox`
44
GARDEN=$(VENV_NAME)/bin/garden
55
PYTHON=$(VENV_NAME)/bin/python
6+
# using full path so it can be used outside the root dir
7+
SPHINXBUILD=$(shell realpath venv/bin/sphinx-build)
8+
DOCS_DIR=doc
69
SYSTEM_DEPENDENCIES= \
710
build-essential \
811
cmake \
@@ -21,13 +24,19 @@ PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
2124
# python3 has a "m" suffix for both include path and library
2225
PYTHON_M=$(PYTHON_WITH_VERSION)
2326
SITE_PACKAGES_DIR=$(VENV_NAME)/lib/$(PYTHON_WITH_VERSION)/site-packages
27+
TMPDIR ?= /tmp
28+
DOWNLOAD_DIR = $(TMPDIR)/downloads
2429
OPENCV_VERSION=4.0.1
25-
OPENCV_ARCHIVE=$(OPENCV_BASENAME).tar.gz
2630
OPENCV_BASENAME=opencv-$(OPENCV_VERSION)
27-
OPENCV_BUILD_LIB_DIR=$(OPENCV_BASENAME)/build/lib
31+
OPENCV_ARCHIVE=$(OPENCV_BASENAME).tar.gz
32+
OPENCV_ARCHIVE_PATH=$(DOWNLOAD_DIR)/$(OPENCV_ARCHIVE)
33+
OPENCV_EXTRACT_PATH=$(DOWNLOAD_DIR)/$(OPENCV_BASENAME)
34+
OPENCV_BUILD_LIB_DIR=$(OPENCV_EXTRACT_PATH)/build/lib
2835
OPENCV_BUILD=$(OPENCV_BUILD_LIB_DIR)/python$(PYTHON_MAJOR_VERSION)/cv2*.so
2936
OPENCV_DEPLOY=$(SITE_PACKAGES_DIR)/cv2*.so
3037
NPROC=`grep -c '^processor' /proc/cpuinfo`
38+
39+
3140
ifeq ($(PYTHON_MAJOR_VERSION), 3)
3241
PYTHON_M := $(PYTHON_M)m
3342
endif
@@ -38,7 +47,7 @@ all: system_dependencies virtualenv opencv
3847
venv:
3948
test -d venv || virtualenv -p python$(PYTHON_MAJOR_VERSION) venv
4049
. venv/bin/activate
41-
$(PIP) install Cython==0.26.1
50+
$(PIP) install Cython==0.28.6
4251
$(PIP) install -r requirements/requirements.txt
4352
$(GARDEN) install xcamera
4453

@@ -49,14 +58,15 @@ ifeq ($(OS), Ubuntu)
4958
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
5059
endif
5160

52-
$(OPENCV_ARCHIVE):
61+
$(OPENCV_ARCHIVE_PATH):
62+
mkdir -p $(DOWNLOAD_DIR)
5363
curl --location https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).tar.gz \
54-
--progress-bar --output $(OPENCV_ARCHIVE)
64+
--progress-bar --output $(OPENCV_ARCHIVE_PATH)
5565

5666
# The build also relies on virtualenv, because we make references to it.
5767
# Plus numpy is required to build OpenCV Python module.
58-
$(OPENCV_BUILD): $(OPENCV_ARCHIVE) virtualenv
59-
tar -xf $(OPENCV_BASENAME).tar.gz
68+
$(OPENCV_BUILD): $(OPENCV_ARCHIVE_PATH) virtualenv
69+
tar -xf $(OPENCV_ARCHIVE_PATH) --directory $(DOWNLOAD_DIR)
6070
cmake \
6171
-D CMAKE_SHARED_LINKER_FLAGS=-l$(PYTHON_M) \
6272
-D BUILD_SHARED_LIBS=ON \
@@ -90,20 +100,23 @@ $(OPENCV_BUILD): $(OPENCV_ARCHIVE) virtualenv
90100
-D WITH_JASPER=OFF \
91101
-D WITH_OPENEXR=OFF \
92102
-D WITH_PVAPI=OFF \
93-
-B$(OPENCV_BASENAME)/build -H$(OPENCV_BASENAME)
94-
cmake --build $(OPENCV_BASENAME)/build -- -j$(NPROC)
103+
-B$(OPENCV_EXTRACT_PATH)/build -H$(OPENCV_EXTRACT_PATH)
104+
cmake --build $(OPENCV_EXTRACT_PATH)/build -- -j$(NPROC)
95105

96106
$(OPENCV_DEPLOY): $(OPENCV_BUILD) virtualenv
97107
cp $(OPENCV_BUILD) $(SITE_PACKAGES_DIR)
98108

99109
opencv: $(OPENCV_DEPLOY)
100110

101111
clean:
102-
rm -rf $(VENV_NAME) .tox/ $(OPENCV_BASENAME)
112+
rm -rf $(VENV_NAME) .tox/ $(DOWNLOAD_DIR) $(DOCS_DIR)/build/ dist/ build/
103113

104114
test:
105115
$(TOX)
106116

107117
uitest: virtualenv
108118
$(PIP) install -r requirements/test_requirements.txt
109119
$(PYTHON) -m unittest discover --top-level-directory=. --start-directory=tests/ui/
120+
121+
docs:
122+
cd $(DOCS_DIR) && SPHINXBUILD=$(SPHINXBUILD) make html

OpenCV.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ make system_dependencies
1010
make opencv
1111
```
1212
It would build OpenCV and deploy it to your virtualenv.
13+
14+
## Troubleshooting
15+
16+
### Makefile `cp: cannot stat 'opencv-4.0.1/build/lib/python3/cv2*.so': No such file or directory`
17+
Log:
18+
```
19+
make[2]: Leaving directory '/tmp/trash/zbarcam/opencv-4.0.1/build'
20+
make[1]: Leaving directory '/tmp/trash/zbarcam/opencv-4.0.1/build'
21+
cp opencv-4.0.1/build/lib/python3/cv2*.so venv/lib/python3.7/site-packages
22+
cp: cannot stat 'opencv-4.0.1/build/lib/python3/cv2*.so': No such file or directory
23+
Makefile:97: recipe for target 'venv/lib/python3.7/site-packages/cv2*.so' failed
24+
make: *** [venv/lib/python3.7/site-packages/cv2*.so] Error 1
25+
```
26+
Most likely you need to `pip install numpy` delete your opencv build and build again.

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# garden.zbarcam
1+
# zbarcam
22

3-
[![Build Status](https://secure.travis-ci.org/kivy-garden/garden.zbarcam.png?branch=develop)](http://travis-ci.org/kivy-garden/garden.zbarcam)
3+
[![Build Status](https://travis-ci.org/kivy-garden/zbarcam.svg?branch=develop)](https://travis-ci.org/kivy-garden/zbarcam)
44

55
Real time Barcode and QR Code scanner using the camera.
66
It's built on top of [Kivy](https://github.com/kivy/kivy) and [pyzbar](https://github.com/NaturalHistoryMuseum/pyzbar).
@@ -10,7 +10,7 @@ It's built on top of [Kivy](https://github.com/kivy/kivy) and [pyzbar](https://g
1010
## How to use
1111
Simply import and instanciate `ZBarCam` in your kvlang file and access its `symbols` property.
1212
```yaml
13-
#:import ZBarCam kivy.garden.zbarcam
13+
#:import ZBarCam kivy_garden.zbarcam.ZBarCam
1414
#:import ZBarSymbol pyzbar.pyzbar.ZBarSymbol
1515
BoxLayout:
1616
orientation: 'vertical'
@@ -23,6 +23,7 @@ BoxLayout:
2323
size: self.texture_size[0], 50
2424
text: ', '.join([str(symbol.data) for symbol in zbarcam.symbols])
2525
```
26+
A full working demo is available in [kivy_garden/zbarcam/main.py](kivy_garden/zbarcam/main.py).
2627
2728
## Install
2829
@@ -34,19 +35,19 @@ sudo apt install libzbar-dev
3435

3536
Install garden requirements:
3637
```sh
37-
garden install xcamera
38+
garden install --upgrade xcamera
3839
```
3940

4041
Install zbarcam:
41-
Via `garden`:
4242
```sh
43-
garden install --upgrade zbarcam
43+
pip install --upgrade https://github.com/kivy-garden/zbarcam/archive/develop.zip
4444
```
45-
Via `pip`:
46-
```sh
47-
pip install --upgrade https://github.com/kivy-garden/garden.zbarcam/archive/develop.zip
45+
Then import it in your Python code via:
46+
```python
47+
from kivy_garden.zbarcam import ZBarCam
4848
```
4949

50+
5051
You may also need to compile/install OpenCV manually, see [OpenCV.md](OpenCV.md).
5152

5253
### Android
@@ -66,15 +67,15 @@ make uitest
6667
## Troubleshooting
6768

6869
### Install `Unable to import package 'kivy.garden.xcamera.XCamera'`
69-
Missing the `xcamera` dependency, install it with:
70-
```sh
71-
garden install xcamera
72-
```
70+
You're missing the `xcamera` dependency. Install it as described in the install instructions.
7371

7472
### Android `ValueError: Empty module name`
7573
More likely an import issue in your `.kv` file.
7674
Try to `from zbarcam import ZBarCam` in your `main.py` to see the exact error.
7775
It's common to forget `Pillow` in `buildozer.spec` `requirements` section.
7876

77+
### OpenCV related
78+
See [OpenCV.md](OpenCV.md).
79+
7980
## Credits
8081
I borrowed a lot of code from [tito/android-zbar-qrcode](https://github.com/tito/android-zbar-qrcode).

buildozer.spec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package.name = zbarcamdemo
1010
package.domain = com.github.andremiras
1111

1212
# (str) Source code where the main.py live
13-
source.dir = .
13+
source.dir = src
1414

1515
# (list) Source files to include (let empty to include all the files)
1616
source.include_exts = py,png,jpg,kv,atlas
@@ -22,7 +22,7 @@ source.include_exts = py,png,jpg,kv,atlas
2222
#source.exclude_exts = spec
2323

2424
# (list) List of directory to exclude (let empty to not exclude anything)
25-
source.exclude_dirs = tests, bin, venv, opencv-*
25+
#source.exclude_dirs = tests, bin
2626

2727
# (list) List of exclusions using pattern matching
2828
#source.exclude_patterns = license,images/*/*.jpg
@@ -32,7 +32,7 @@ source.exclude_dirs = tests, bin, venv, opencv-*
3232

3333
# (str) Application versioning (method 2)
3434
version.regex = __version__ = ['"](.*)['"]
35-
version.filename = %(source.dir)s/zbarcam/version.py
35+
version.filename = %(source.dir)s/kivy_garden/zbarcam/version.py
3636
3737
# (list) Application requirements
3838
# comma seperated e.g. requirements = sqlite3,kivy

doc/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Generating the Docs
2+
===================
3+
4+
Basic instructions for how to generate the flower docs and upload to github.
5+
This needs to be done in either powershell or linux shell, not windows cmd.
6+
7+
The generated docs can be found at https://kivy-garden.github.io/flower/ after this
8+
process.
9+
10+
Please use these instructions with care and don't copy paste without understanding
11+
what the commands do as they create and delete folders. Make sure the repo is
12+
fully pushed to github before doing this because this **deletes** all local changes.
13+
14+
You may want to do the following commands in a copy of the flower directory.
15+
16+
Install sphinx::
17+
18+
python -m pip install sphinx
19+
20+
In a shell make sure to be in the flower directory. Then::
21+
22+
cd doc
23+
# (in powershell do ./make.bat html)
24+
make html
25+
cd ..
26+
27+
mkdir ~/docs_temp
28+
# copy generated docs to temp path
29+
cp -r doc/build/html/* ~/docs_temp
30+
# gh-pages is the branch for the docs that github will display
31+
git checkout --orphan gh-pages
32+
# **CAUTION** be sure the following commands is executed in the flower directory
33+
# we take no responsibility if you delete all the files in your computer :)
34+
git rm -rf .
35+
# on a linux shell do
36+
rm -fr $(ls -1 --ignore=.git .)
37+
# in powershell instead do
38+
Remove-Item -recurse * -exclude .git
39+
# copy the docs back to the repo
40+
cp -r ~/docs_temp/* .
41+
echo "" > .nojekyll
42+
43+
git add .
44+
git commit -a -m "Docs update"
45+
git push origin gh-pages -f
46+
47+
# Finally, get back to master
48+
git checkout master

doc/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

0 commit comments

Comments
 (0)