Skip to content

Commit

Permalink
[#372] pydmtxlib
Browse files Browse the repository at this point in the history
  • Loading branch information
quicklizard99 committed Nov 2, 2016
1 parent cc84318 commit 10443d9
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cover
MANIFEST
*spec
!inselect.spec
!read_barcodes.spec
!segment.spec
*tar.gz
*dmg
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ This is an overview of major changes. Refer to the git repository for a full log

Version 0.1.35
-------------
- #372 Support pydmtxlib
- #273 Inselect as a package
- #83 Architecture and code organisation

Expand Down
17 changes: 0 additions & 17 deletions DevelopingOnLinux.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,6 @@ mkvirtualenv --system-site-packages inselect
pip2 install -r requirements.pip
```

## LibDMTX barcode reading library

* Get source for the wrappers

```
cd ~/projects
git clone git://libdmtx.git.sourceforge.net/gitroot/libdmtx/dmtx-wrappers
```
* Install Python library
```
cd dmtx-wrappers/python
python2 setup.py install
cd ~/projects/inselect
```
## Test barcode reading libraries

Inselect has optional barcode reading capabilities. The dependent libraries
Expand Down
34 changes: 3 additions & 31 deletions DevelopingOnMacOSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,16 @@ pip install -r requirements.pip

## LibDMTX barcode reading library

* Get source for the library and the wrappers
* Install the `libdmtx` shared lib

```
cd ~/projects
git clone git://libdmtx.git.sourceforge.net/gitroot/libdmtx/libdmtx
git clone git://libdmtx.git.sourceforge.net/gitroot/libdmtx/dmtx-wrappers
```
* Build library
```
cd libdmtx
git checkout v0.7.4
./autogen.sh
./configure
make
```
* Build Python library
```
cd ../dmtx-wrappers/
./autogen.sh
./configure
make
```
* Install Python library
```
cd python
python setup.py install
brew install libdmtx
```
* Test
```
python -c "import pydmtx; print(pydmtx)"
python -c "import libdmtx; print(libdmtx)"
```
## Test barcode reading libraries
Expand Down
14 changes: 7 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ python -c "from gouda.engines import LibDMTXEngine; assert LibDMTXEngine.availab
echo Report startup time and check for non-essential binary imports
mkdir build
time python -v inselect.py --quit &> build/startup_log
for module in cv2 numpy pydmtx scipy sklearn zbar; do
for module in cv2 numpy libdmtx scipy sklearn zbar; do
if grep -q $module build/startup_log; then
echo Non-essential binary $module imported on startup
exit 1
Expand All @@ -37,17 +37,17 @@ echo Source build
mv dist/inselect-$VERSION.tar.gz .

if [[ "$OSTYPE" == "darwin"* ]]; then
# Clean existing build files
pyinstaller --clean inselect.spec
# Scripts that have additional requirements in theie own spec files
for script in inselect read_barcodes segment; do
pyinstaller --clean $script.spec
done

for script in export_metadata ingest read_barcodes save_crops; do
# Scripts for which the .spec file can be generated
for script in export_metadata ingest save_crops; do
rm -rf $script.spec
pyinstaller --onefile --hidden-import numpy inselect/scripts/$script.py
done

# segment has additional requirements so have its own spec file
pyinstaller --clean segment.spec

# Add a few items to the PropertyList file generated by PyInstaller
python -m bin.plist dist/inselect.app/Contents/Info.plist
# Example document
Expand Down
10 changes: 7 additions & 3 deletions inselect.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ block_cipher = None

a = Analysis(['inselect.py'],
pathex=[str(Path('.').absolute())],
binaries=None,
binaries=[],
datas=[('inselect/inselect.qss', '')],
hiddenimports=['sklearn.neighbors.typedefs'],
hiddenimports=['sklearn.neighbors.typedefs', 'libdmtx'],
hookspath=[],
runtime_hooks=[],
excludes=['Tkinter'],
Expand All @@ -19,11 +19,15 @@ a = Analysis(['inselect.py'],
cipher=block_cipher)


# libdmtx dylib is not detected because it is loaded by a ctypes call
a.binaries += TOC([
('libdmtx.dylib', '/usr/local/Cellar/libdmtx/0.7.4/lib/libdmtx.dylib', 'BINARY'),
])

# 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 = (
'libiomp5.dylib',
'libmkl_intel_lp64.dylib',
Expand Down
5 changes: 3 additions & 2 deletions inselect/scripts/read_barcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

try:
import gouda
except ImportError:
gouda = engine_options = resize = roi = None
else:
from gouda.engines.options import engine_options
from gouda.strategies.resize import resize
from gouda.strategies.roi.roi import roi
except ImportError:
gouda = engine_options = resize = roi = None


class BarcodeReader(object):
Expand Down
66 changes: 66 additions & 0 deletions read_barcodes.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import sys

from pathlib import Path

block_cipher = None


a = Analysis(['inselect/scripts/read_barcodes.py'],
pathex=[str(Path('.').absolute())],
binaries=[],
datas=None,
hiddenimports=['numpy', 'libdmtx'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)


# libdmtx dylib is not detected because it is loaded by a ctypes call
a.binaries += TOC([
('libdmtx.dylib', '/usr/local/Cellar/libdmtx/0.7.4/lib/libdmtx.dylib', 'BINARY'),
])

# 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 = (
'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')

# 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)

exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='read_barcodes',
debug=False,
strip=False,
upx=True,
console=True )
1 change: 1 addition & 0 deletions requirements.pip
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exifread==2.1.2
humanize==0.5.1
pathlib==1.0.1
psutil==4.0.0
pylibdmtx==0.1.0
python-dateutil==2.3 # 2.5.0 causes problems for PyInstaller builds on Mac OS X
pytz==2015.7
PyYAML==3.11
Expand Down
1 change: 0 additions & 1 deletion requirements.win32
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
https://github.com/NaturalHistoryMuseum/dmtx-wrappers/releases/download/v0.7.4b1/pydmtx-0.7.4b1-cp27-none-win32.whl
https://github.com/NaturalHistoryMuseum/zbar-python-patched/releases/download/v0.10/zbar-0.10-cp27-none-win32.whl
1 change: 0 additions & 1 deletion requirements.win64
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
https://github.com/NaturalHistoryMuseum/dmtx-wrappers/releases/download/v0.7.4b1/pydmtx-0.7.4b1-cp27-none-win_amd64.whl
https://github.com/NaturalHistoryMuseum/ZBarWin64/releases/download/v0.10/zbar-0.10-cp27-none-win_amd64.whl
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'install_requires': REQUIREMENTS,
'extras_require': {
'gui': ['exifread>=2.1.2', 'humanize>=0.5.1', 'psutil>=4.0.0', 'PySide>=1.2.1'],
'barcodes': ['gouda>=0.1.6', 'pydmtx>=0.7.4b1', 'zbar>=0.10'],
'barcodes': ['gouda>=0.1.8', 'pylibdmtx>=0.1.0', 'zbar>=0.10'],
'windows': ['pywin32>=220'],
'development': ['coveralls>=0.4.1', 'mock>=1.0.1', 'nose>=1.3.4'],
},
Expand Down

0 comments on commit 10443d9

Please sign in to comment.