Skip to content

Commit

Permalink
Merge pull request #22 from NaturalHistoryMuseum/feature/21-build-scr…
Browse files Browse the repository at this point in the history
…ipts

Feature/21 build scripts
  • Loading branch information
quicklizard99 authored Aug 31, 2016
2 parents f8c1498 + 6a442e5 commit ce501e8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 7 additions & 3 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
59 changes: 30 additions & 29 deletions decode_barcodes.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gouda/tests/test_decode_barcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ce501e8

Please sign in to comment.