From 8e9202aa0b595694f40b8a095bc791271f069bf6 Mon Sep 17 00:00:00 2001 From: Lawrence Hudson Date: Wed, 31 Aug 2016 12:11:58 +0100 Subject: [PATCH 1/4] [#21] Build script and spec file on Windows --- build.bat | 10 +++++--- decode_barcodes.spec | 59 ++++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/build.bat b/build.bat index 60ae2a6..25ebdd3 100644 --- a/build.bat +++ b/build.bat @@ -2,10 +2,14 @@ REM Temporary solution until I get round to writing a makefile echo Clean del /S *pyc -del *spec rmdir /Q /S dist build +echo Check for presence of barcode engines +python -c "from gouda.engines import ZbarEngine; assert ZbarEngine.available()" || exit /b +python -c "from gouda.engines import LibDMTXEngine; assert LibDMTXEngine.available()" || exit /b +python -c "from gouda.engines import InliteEngine; assert InliteEngine.available()" || exit /b + echo Tests -nosetests --with-coverage --cover-html --cover-inclusive --cover-erase --cover-tests --cover-package=gouda +nosetests --with-coverage --cover-html --cover-inclusive --cover-erase --cover-tests --cover-package=gouda || exit /b -pyinstaller --onefile --specpath=build gouda/scripts/decode_barcodes.py +pyinstaller --onefile --clean decode_barcodes.spec || exit /b diff --git a/decode_barcodes.spec b/decode_barcodes.spec index 867a8c4..339e9cf 100644 --- a/decode_barcodes.spec +++ b/decode_barcodes.spec @@ -18,38 +18,39 @@ a = Analysis(['gouda/scripts/decode_barcodes.py'], win_private_assemblies=False, cipher=block_cipher) -# PyInstaller does not detect some dylibs, I think in some cases because they -# are symlinked. -# See Stack Overflow post http://stackoverflow.com/a/17595149 for example -# of manipulating Analysis.binaries. +if 'darwin' == sys.platform: + # PyInstaller does not detect some dylibs, I think in some cases because they + # are symlinked. + # See Stack Overflow post http://stackoverflow.com/a/17595149 for example + # of manipulating Analysis.binaries. -MISSING_DYLIBS = ( - 'libpng16.16.dylib', - 'libz.1.dylib', - 'libopencv_contrib.2.4.dylib', - 'libopencv_nonfree.2.4.dylib', - 'libopencv_gpu.2.4.dylib', - 'libopencv_legacy.2.4.dylib', - 'libopencv_photo.2.4.dylib', - 'libopencv_ocl.2.4.dylib', - 'libopencv_calib3d.2.4.dylib', - 'libopencv_features2d.2.4.dylib', - 'libopencv_flann.2.4.dylib', - 'libopencv_ml.2.4.dylib', - 'libopencv_video.2.4.dylib', - 'libopencv_objdetect.2.4.dylib', - 'libopencv_highgui.2.4.dylib', - 'libopencv_imgproc.2.4.dylib', - 'libopencv_core.2.4.dylib', -) + MISSING_DYLIBS = ( + 'libpng16.16.dylib', + 'libz.1.dylib', + 'libopencv_contrib.2.4.dylib', + 'libopencv_nonfree.2.4.dylib', + 'libopencv_gpu.2.4.dylib', + 'libopencv_legacy.2.4.dylib', + 'libopencv_photo.2.4.dylib', + 'libopencv_ocl.2.4.dylib', + 'libopencv_calib3d.2.4.dylib', + 'libopencv_features2d.2.4.dylib', + 'libopencv_flann.2.4.dylib', + 'libopencv_ml.2.4.dylib', + 'libopencv_video.2.4.dylib', + 'libopencv_objdetect.2.4.dylib', + 'libopencv_highgui.2.4.dylib', + 'libopencv_imgproc.2.4.dylib', + 'libopencv_core.2.4.dylib', + ) -# The lib directory associated with this environment -LIB = Path(sys.argv[0]).parent.parent.joinpath('lib') + # The lib directory associated with this environment + LIB = Path(sys.argv[0]).parent.parent.joinpath('lib') -# Find the source for each library and add it to the list of binaries -a.binaries += TOC([ - (lib, str(LIB.joinpath(lib).resolve()), 'BINARY') for lib in MISSING_DYLIBS -]) + # Find the source for each library and add it to the list of binaries + a.binaries += TOC([ + (lib, str(LIB.joinpath(lib).resolve()), 'BINARY') for lib in MISSING_DYLIBS + ]) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) From 513817ef4ede24ce7609afb9d025107d8f96532b Mon Sep 17 00:00:00 2001 From: Lawrence Hudson Date: Wed, 31 Aug 2016 12:17:40 +0100 Subject: [PATCH 2/4] [#21] Fix test on Windows --- gouda/tests/test_decode_barcodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gouda/tests/test_decode_barcodes.py b/gouda/tests/test_decode_barcodes.py index 8d02c16..20794b8 100644 --- a/gouda/tests/test_decode_barcodes.py +++ b/gouda/tests/test_decode_barcodes.py @@ -48,7 +48,7 @@ def test_rename_with_collisions(self): main(['zbar', '--action=rename', unicode(tempdir)]) self.assertEqual( ['Stegosaurus.png', 'first copy.png', 'second copy.png'], - [path.name for path in sorted(tempdir.iterdir())] + [path.name for path in sorted(tempdir.iterdir(), key=lambda p: p.name)] ) def test_rename_avoid_collisions(self): From 70a4867213e7093abb3e166a63dcc9fc3d4a7afd Mon Sep 17 00:00:00 2001 From: Lawrence Hudson Date: Wed, 31 Aug 2016 12:44:23 +0100 Subject: [PATCH 3/4] [#21] Check barcode readers are present --- build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.sh b/build.sh index e54c94d..8a91d66 100755 --- a/build.sh +++ b/build.sh @@ -7,6 +7,10 @@ find . -name "*pyc" -print0 | xargs -0 rm -rf find . -name __pycache__ -print0 | xargs -0 rm -rf rm -rf dist build cover +echo Check for presence of barcode engines +python -c "from gouda.engines import ZbarEngine; assert ZbarEngine.available()" || exit /b +python -c "from gouda.engines import LibDMTXEngine; assert LibDMTXEngine.available()" || exit /b + echo Tests nosetests --with-coverage --cover-html --cover-inclusive --cover-erase --cover-tests --cover-package=gouda From 6a442e564b824fd049a75d4308920495fe8b635c Mon Sep 17 00:00:00 2001 From: Lawrence Hudson Date: Wed, 31 Aug 2016 12:45:10 +0100 Subject: [PATCH 4/4] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e555e9..bd0e885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # v0.1.7 +- #21 Build scripts to exit on failure - #15 Mac OS X build of decode_barcodes - #14 Suffixes to resolve filename collisions