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/95 python3 #403

Merged
merged 46 commits into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
625fbe0
[#395] PyQt5
quicklizard99 Nov 30, 2016
6b62d14
[#395] PyQt5 Windows
quicklizard99 Nov 30, 2016
44c805b
Merge master
quicklizard99 Nov 30, 2016
e5e6b38
Merge branch 'feature/395-qt5' of github.com:NaturalHistoryMuseum/ins…
quicklizard99 Nov 30, 2016
faa539c
[#395] Global exception handler to paly nicely with Qt5
quicklizard99 Dec 1, 2016
fc082a7
Merge branch 'master' into feature/395-qt5
quicklizard99 Dec 1, 2016
fdd676f
[#395] work on Mac OS X build
quicklizard99 Dec 1, 2016
b8e8870
[#395] attempt to fix travis
quicklizard99 Dec 1, 2016
110b93d
[#395] another attempt to fix travis - anaconda is pain
quicklizard99 Dec 1, 2016
afeb8a1
PyQt version
quicklizard99 Dec 1, 2016
458cb97
[#395] qt5 supports cosmetic pens with non-zero pixel width
quicklizard99 Dec 2, 2016
b09f49f
[#95] Python 3
quicklizard99 Dec 2, 2016
1803717
[#95] Python 3 on Windows
quicklizard99 Dec 2, 2016
ba7782c
[#95] More work towards Python 3 on Windows
quicklizard99 Dec 2, 2016
a63c3e4
[#95] Miniconda for Python 3
quicklizard99 Dec 5, 2016
16b791e
[#95] Tweak Linux instructions
quicklizard99 Dec 5, 2016
ad600bf
[#95] Travis tweaks
quicklizard99 Dec 5, 2016
d65af38
[#95] Travis tweaks
quicklizard99 Dec 5, 2016
63a7e86
[#95] Attempt to fix travis
quicklizard99 Dec 5, 2016
0177e66
[#95] Yet another attempt to fix travis
quicklizard99 Dec 5, 2016
b0b6855
[#95] Fixes for Windows build
quicklizard99 Dec 6, 2016
9a14432
[#95] Windows build
quicklizard99 Dec 7, 2016
0fc956d
[#95] Correct keyword arg name
quicklizard99 Dec 7, 2016
2cac149
[#95] Mac build
quicklizard99 Dec 8, 2016
e886746
[#95] Remove sdist
quicklizard99 Dec 8, 2016
1cd644a
[#95] Reinstate segment.spec
quicklizard99 Dec 8, 2016
ed869be
[#95] Reinstate segment.spec
quicklizard99 Dec 8, 2016
9144170
[#95] Code layout
quicklizard99 Dec 8, 2016
23c9ba8
[#95] Removed obsolete file
quicklizard99 Dec 8, 2016
0bd64ab
[#95] Fix Windows build and remove experimental cx_Freeze / OS X nons…
quicklizard99 Dec 8, 2016
d7222cc
[#95] Fix Windows freeze
quicklizard99 Dec 8, 2016
56550a7
[#95] Fix OS X freeze of segment
quicklizard99 Dec 8, 2016
77d2d3b
Merge branch 'feature/95-python3' of github.com:NaturalHistoryMuseum/…
quicklizard99 Dec 8, 2016
1024e11
[#95] Fix DLL import for frozen scripts on Windows
quicklizard99 Dec 8, 2016
815ae99
Merge branch 'feature/95-python3' of https://github.com/NaturalHistor…
quicklizard99 Dec 8, 2016
e3ef719
[#95] Consistent box outline width
quicklizard99 Dec 8, 2016
9863386
[#95] Show exception type and value in details box
quicklizard99 Dec 8, 2016
2206be4
[#95] Comment typo
quicklizard99 Dec 8, 2016
74dcb12
[#95] Reinstate test of Inlite engine
quicklizard99 Dec 9, 2016
09c5877
[#95] Update inlite com client
quicklizard99 Dec 9, 2016
e6b0735
[#95] Fix inlite barcode reader when frozen
quicklizard99 Dec 9, 2016
4b41f8e
[#95] Comment
quicklizard99 Dec 9, 2016
e38c4e9
[#95] str / bytes values from barcodes
quicklizard99 Dec 9, 2016
37871d8
[#95] box thickness
quicklizard99 Dec 9, 2016
b5788f4
[#95] Fix inlite barcode reader when frozen
quicklizard99 Dec 9, 2016
9f76163
[#95] Python 3 and Linux
quicklizard99 Dec 12, 2016
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
24 changes: 6 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
language: python

python:
- "2.7"

virtualenv:
system_site_packages: true

before_install:
- sudo apt-get update
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then
sudo apt-get install -y --fix-missing libzbar-dev libdmtx0a;
fi

# We do this conditionally because it saves us some downloading if the
# version is the same.
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- sudo apt-get install -y --fix-missing libzbar-dev libdmtx0a libegl1-mesa libx11-xcb1;
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update --yes conda
# Useful for debugging any issues with conda
- conda info -a

- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pillow pyqt numpy scikit-learn opencv
- source activate test-environment
- python setup.py install
- conda env create -f inselect.yml
- source activate inselect

install:
- pip install -r requirements.pip
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- pyrcc4 icons.qrc > inselect/gui/icons.py
- pyrcc5 icons.qrc > inselect/gui/icons.py

script:
- nosetests --verbose --with-coverage --cover-inclusive --cover-tests --cover-package=inselect inselect
- nosetests --verbose --with-coverage --cover-inclusive --cover-tests --cover-package=inselect --verbose inselect

after_success:
- coveralls
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Version 0.1.35
-------------
- #401 Support new pyzbar and pylibdmtx
- #397 Couple of problems with keyboard shortcuts box
- #395 PyQt5
- #393 Warning from libpng when running tests
- #391 OpenCV3
- #389 PyQt4
Expand All @@ -17,6 +18,7 @@ Version 0.1.35
- #368 Ugly error message when creating a new inselect document on Mac OS X
- #367 Reveal file doesn't work on Windows
- #273 Inselect as a package
- #95 Python 3
- #83 Architecture and code organisation

Version 0.1.34
Expand Down
53 changes: 26 additions & 27 deletions DevelopingOnLinux.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
# 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`
Tested on Ubuntu 12.04, 14.04 and 16.04, all with 2GB RAM.
Inselect runs on Python 3.4 or later and OpenCV 3.
While Ubuntu provides a `deb` package for Python 3, it does not provide
(at time of writing) a `deb` package of Python 3 bindings for `OpenCV`.
For these reasons, and to provide a consistent environment among distributions,
we recommend using
[Continuum's Miniconda](http://conda.pydata.org/miniconda.html) as shown below.
To run Inselect with system packages, you will need to compile OpenCV.

# Install Miniconda

```
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/Miniconda3-latest-Linux-x86_64.sh
bash /tmp/Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda3
rm /tmp/Miniconda3-latest-Linux-x86_64.sh

## Setup virtualenvwrapper
export WORKON_HOME=~/Envs/
source /usr/local/bin/virtualenvwrapper.sh
export PATH=~/miniconda3/bin:$PATH
conda update --yes conda
```

# Inselect env

# Install system dependencies
```
sudo apt-get install python-qt4 pyqt4-dev-tools python-numpy python-scipy python-sklearn python-opencv python-pil libdmtx-dev libzbar-dev
conda env create -f inselect.yml
source activate inselect
pip install -r requirements.pip
```

# Create virtual environment for Inselect and install dependencies from pip
## Install and test barcode reading libraries

Inselect has optional barcode reading capabilities. The dependent libraries
can be installed with

```
mkvirtualenv --system-site-packages --python=/usr/bin/python2 inselect
pip2 install -r requirements.pip
sudo apt-get install libzbar-dev libdmtx0a
```

## Test barcode reading libraries

Inselect has optional barcode reading capabilities. The dependent libraries
should have been installed.
Test

```
python -c "from gouda.engines import ZbarEngine; print(ZbarEngine.available())"
Expand All @@ -51,7 +50,7 @@ Icons are stored as individual files in `icons`. They are frozen into
a python file `inselect/gui/icons.py` by running

```
pyrcc4 icons.qrc > inselect/gui/icons.py
pyrcc5 icons.qrc > inselect/gui/icons.py
```

# Test and run
Expand All @@ -72,5 +71,5 @@ python -m nose --verbose --with-coverage --cover-inclusive --cover-tests --cover
Run inselect

```
./inselect.py
python -m inselect.scripts.inselect
```
24 changes: 18 additions & 6 deletions DevelopingOnMacOSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ brew install upx zbar libdmtx
# Install Miniconda

```
wget https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh -O /tmp/Miniconda-latest-MacOSX-x86_64.sh
bash /tmp/Miniconda-latest-MacOSX-x86_64.sh -b -p $HOME/miniconda
rm /tmp/Miniconda-latest-MacOSX-x86_64.sh
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O /tmp/Miniconda3-latest-MacOSX-x86_64.sh
bash /tmp/Miniconda3-latest-MacOSX-x86_64.sh -b -p $HOME/miniconda3
rm /tmp/Miniconda3-latest-MacOSX-x86_64.sh

export PATH=~/miniconda/bin:$PATH
export PATH=~/miniconda3/bin:$PATH
conda update --yes conda
```

# Inselect env

```
conda env create -f inselect-osx.yml
conda env create -f inselect.yml
source activate inselect
pip install -r requirements.pip
```
Expand All @@ -45,7 +45,19 @@ Icons are stored as individual files in `icons`. They are frozen into
a python file `inselect/gui/icons.py` by running

```
pyrcc4 icons.qrc > inselect/gui/icons.py
pyrcc5 icons.qrc > inselect/gui/icons.py
```

# Test and run

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

Run inselect

```
python -m inselect.scripts.inselect
```

# Build
Expand Down
69 changes: 25 additions & 44 deletions DevelopingOnWindows.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
Windows is complicated by the fact that we provide both 32-bit and 64-bit builds
of Inselect

# Install Miniconda 64 bit
* Download and run [Miniconda-latest-Windows-x86_64.exe](https://repo.continuum.io/miniconda/)
# Install Miniconda3 64 bit
* Download and run [Miniconda3-latest-Windows-x86_64.exe](https://repo.continuum.io/miniconda/)

* Destination folder should be called Miniconda64
* Uncheck 'Add Anaconda to my PATH'
* Uncheck 'Register Anaconda as my default Python 2.7'

## Minicoda64 shortcut
## Minicoda3-64 shortcut

I find it useful to have a shortcut on the desktop and taskbar, configured as
follows:

* Target: `C:\Windows\System32\cmd.exe /k "C:\Users\<your Windows username>\Miniconda64\Scripts\activate.bat"`
* Name Miniconda64
* Name Miniconda3-64
* Start in: `C:\Users\<your Windows username>\`
* Font: Consolas, 16
* Layout: Buffer size, Width: 140
* Layout: Window size, Width: 140


# Install Miniconda 32 bit
* Download and run [Miniconda-latest-Windows-x86.exe](https://repo.continuum.io/miniconda/)
* Destination folder should be called Miniconda32
# Install Miniconda3 32 bit
* Download and run [Miniconda3-latest-Windows-x86.exe](https://repo.continuum.io/miniconda/)
* Destination folder should be called Miniconda32-3
* Uncheck 'Add Anaconda to my PATH'

## Miniconda32 shortcut
## Miniconda3-32 shortcut

I find it useful to have a shortcut on the desktop and taskbar, configured as
follows:

* Target: `C:\Windows\System32\cmd.exe /k "C:\Users\<your Windows username>\Miniconda32\Scripts\activate.bat"`
* Name Miniconda32
* Name Miniconda3-32
* Start in: `C:\Users\<your Windows username>\`
* Font: Consolas, 16
* Layout: Buffer size, Width: 140
Expand All @@ -45,51 +45,20 @@ follows:
You should run through these for both the 32-bit and 64-bit environments that
you created above.

## Install Visual C++ compiler for Python 2.7

This is required to build `cx_Freeze`.
Download from http://aka.ms/vcpython27 and install with defaults.

## Inselect environment

```
# Visual C++ is required to build cx_Freeze
"%HOMEPATH%\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat"

conda update --yes conda
conda env create -f inselect-win.yml
conda env create -f inselect.yml
activate inselect

pip install -r requirements.pip

conda install pywin32=220
FOR /F %a IN ('python -c "import sys; print(sys.exec_prefix)"') DO %a\python %a\Scripts\pywin32_postinstall.py -install
pip install -r requirements.pip
```

Don't worry about the "Can't install shortcuts..." message when you run the
`pywin32_postinstall` step.

## Install OpenCV
* Download [OpenCV 3.1.0](http://opencv.org/)
* Extract OpenCV to `c:\opencv-3.1.0\`
* Copy the extension module to the Anaconda environment; for 64-bit:

```
FOR /F %a IN ('python -c "import sys; print(sys.exec_prefix)"') DO copy C:\opencv-3.1.0\build\python\2.7\x64\cv2.pyd %a\DLLs
```

For 32-bit:

```
FOR /F %a IN ('python -c "import sys; print(sys.exec_prefix)"') DO copy C:\opencv-3.1.0\build\python\2.7\x86\cv2.pyd %a\DLLs
```


* Test

```
python -c "import cv2; print cv2.__version__"
```

### Inlite barcode reading library
Download and install the [Inlite ClearImage SDK](http://www.inliteresearch.com/).
Run the 'Inlite Control Center' application to get an evaluation key.
Expand All @@ -111,7 +80,19 @@ Icons are stored as individual files in `icons`. They are frozen into
a python file `inselect/gui/icons.py` by running

```
pyrcc4 icons.qrc > inselect/gui/icons.py
pyrcc5 icons.qrc > inselect/gui/icons.py
```

# Test and run

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

Run inselect

```
python -m inselect.scripts.inselect
```

# Build
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Inselect is written in [Python](https://www.python.org/), [Qt](http://www.qt.io/
and [OpenCV](http://opencv.org/). Read instructions for
[developing on Mac OS X](DevelopingOnMacOSX.md),
[developing on Windows](DevelopingOnWindows.md) and [releasing](Releasing.md).
Versions of Inselect between v0.1.1 to v0.1.34 inclusive run on Python 2.7.
Starting with v0.1.35, Inselect runs on Python 3 only. This should not affect
you unless you are running Inselect on Linux - see
[developing on Linux](DevelopingOnLinux.md) for instructions.

## License

Expand Down
2 changes: 1 addition & 1 deletion bin/plist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
"""Alter Inselect's existing plist file
"""

Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ del /S *pyc
rmdir /Q /S dist build

echo Freeze icons
pyrcc4 icons.qrc > inselect/gui/icons.py || exit /b
pyrcc5 icons.qrc > inselect/gui/icons.py || exit /b

echo Check for presence of barcode engines
python -c "from gouda.engines import ZbarEngine; assert ZbarEngine.available()" || exit /b
Expand Down
14 changes: 7 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set -e # Exit on failure

# Icons needs to be frozen before running inselect.py
echo Freeze icons
pyrcc4 icons.qrc > inselect/gui/icons.py
pyrcc5 icons.qrc > inselect/gui/icons.py

VERSION=`python inselect.py --version 2>&1 | sed 's/inselect.py //g'`
VERSION=`python -m inselect.scripts.inselect --version 2>&1 | sed 's/inselect.py //g'`

echo Building Inselect $VERSION

Expand All @@ -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
time python -v -m inselect.scripts.inselect --quit &> build/startup_log
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
Expand All @@ -33,12 +33,12 @@ done
echo Tests
nosetests --with-coverage --cover-html --cover-inclusive --cover-erase --cover-tests --cover-package=inselect inselect

echo Source build
./setup.py sdist
mv dist/inselect-$VERSION.tar.gz .
echo Wheel build
./setup.py bdist_wheel --universal
mv dist/inselect-*.whl .

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