Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/349 linux #350

Merged
merged 8 commits into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.34
-------------
- #349 Linux instructions
- #347 Explicitly reference python2 in scripts
- #342 Conda environment files
- #333 Ugly error message when opening or saving a file
Expand Down
93 changes: 93 additions & 0 deletions DevelopingOnLinux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Inselect on Linux

These instructions use the system's Python and many system python packages.
Tested on Ubuntu 14.04 and 16.04, both with 2GB RAM.
For an approach using `miniconda` see `.travis.yml`.

# Setup Python virtual environment

```
sudo apt-get install python-pip python-dev build-essential
sudo pip2 install --upgrade pip
sudo pip2 install virtualenv virtualenvwrapper
```

Append to ``~/.bash_profile`


```

## Setup virtualenvwrapper
export WORKON_HOME=~/Envs/
source /usr/local/bin/virtualenvwrapper.sh
```


# Install system dependencies
```
sudo apt-get install python-pyside pyside-tools python-numpy python-scipy python-sklearn python-opencv python-pil libdmtx-dev libzbar-dev
```

# Create virtual environment for Inselect and install dependencies from pip

```
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
should have been installed.

```
python -c "from gouda.engines import ZbarEngine; print(ZbarEngine.available())"
python -c "from gouda.engines import LibDMTXEngine; print(LibDMTXEngine.available())"
```

# Developing

Icons are stored as individual files in `icons`. They are frozen into
a python file `inselect/gui/icons.py` by running

```
python2 -m bin.freeze_icons
```

# Test and run

```
nosetests --verbose --with-coverage --cover-inclusive --cover-tests --cover-package=inselect inselect
```

Ubuntu 16.04 appears to come with `nose` already installed so the
`pip2 install -r requirements.pip` step above will not install `nose` within
the virtual env. `nosetests` will not find the packages within the
virtualenv and you will see lots of `ImportErrors`. If this is the case, run

```
python -m nose --verbose --with-coverage --cover-inclusive --cover-tests --cover-package=inselect inselect
```

Run inselect

```
./inselect.py
```
5 changes: 4 additions & 1 deletion inselect/lib/sort_document_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _do_kde(values):
bins = np.append(samples[minima], RESCALE)

# Cut data
return (v[0] for v in np.digitize(values, bins, right=True).tolist())
return np.digitize(values.reshape(len(values)), bins, right=True)


def sort_document_items(items, by_columns):
Expand All @@ -36,6 +36,9 @@ def sort_document_items(items, by_columns):
if not items:
# Algorithm is not tolerant of empty values
return []
elif 1 == len(items):
# Breaks algorithm when using older numpy (< 10.1)
return items
else:
rects = [i['rect'] for i in items]
x_bins = _do_kde(r.x_centre for r in rects)
Expand Down