Skip to content

Commit

Permalink
[#117] Windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
quicklizard99 committed Oct 24, 2021
1 parent dadc9d3 commit 64134f4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
27 changes: 8 additions & 19 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,23 @@ rm -rf .tox && tox

### Windows

Save the 32-bit and 64-bit `zbar.dll` files, and their dependencies,
to `libzbar-32.dll` and `libzbar-64.dll` respectively, in the `pyzbar` directory.
The `load_zbar` function in `wrapper.py` looks for the appropriate `DLL`s.
The appropriate `DLL`s are packaged up into the wheel build and is installed
The `pyzbar` directory contains both 32-bit (`libiconv-2.dll` and `libzbar-32.dll`)
and 64-bit (`ibiconv.dll` and `libzbar-64.dll`) DLLs.
The `load_zbar` function in `wrapper.py` looks for the appropriate DLLs.
The appropriate DLLs are packaged up into the wheel build and are installed
alongside the package source. This strategy allows the same method to be used
when `pyzbar` is run from source, as an installed package and when included in a
frozen binary.

## Releasing

1. Build
Create source and wheel builds. The `win32` and `win_amd64` wheels will
contain the appropriate `zbar.dll` and its dependencies.

```
rm -rf build dist MANIFEST.in pyzbar.egg-info
cp MANIFEST.in.all MANIFEST.in
./setup.py bdist_wheel
cat MANIFEST.in.all MANIFEST.in.win32 > MANIFEST.in
./setup.py bdist_wheel --plat-name=win32
Create wheel builds in the `dist` directory. The `win32` and `win_amd64`
wheels will contain the appropriate `zbar.dll` and its dependencies.

# Remove these dirs to prevent win32 DLLs from being included in win64 build
rm -rf build pyzbar.egg-info
cat MANIFEST.in.all MANIFEST.in.win64 > MANIFEST.in
./setup.py bdist_wheel --plat-name=win_amd64
rm -rf build MANIFEST.in pyzbar.egg-info
```
./build.sh
```

2. Release to TestPyPI (see https://packaging.python.org/guides/using-testpypi/)
Expand Down
15 changes: 8 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ provide support for Windows and depends upon Pillow.
Installation
------------

The ``zbar`` ``DLL``\ s are included with the Windows Python wheels.
The ``zbar`` DLLs are included with the Windows Python wheels.
On other operating systems, you will need to install the ``zbar`` shared
library.

Expand Down Expand Up @@ -216,10 +216,11 @@ ZBar versions
Development of the `original zbar <http:https://zbar.sourceforge.net/>`__ stopped in 2012.
Development was started again in 2019 under a `new project <https://github.com/mchehab/zbar/>`__
that has added some new features, including support for decoding
barcode orientation. At the time of writing the project does not produce Windows DLLs.
If you see `orientation=None` then your system has an older release of zbar.
The ``zbar`` ``DLL``\ s that are included with the Windows Python wheels are
an old build that does not support orientation.
barcode orientation. At the time of writing this new project does not produce Windows DLLs.
The ``zbar`` DLLs that are included with the Windows Python wheels are built from the original
project and so do not include support for decoding barcode orientation.
If you see ``orientation=None`` then your system has an older release of zbar that does
not support orientation.

Quality field
-------------
Expand Down Expand Up @@ -264,5 +265,5 @@ License
-------

``pyzbar`` is distributed under the MIT license (see ``LICENCE.txt``).
The ``zbar`` shared library is distributed under the GNU Lesser General
Public License, version 2.1 (see ``zbar-LICENCE.txt``).
The ``zbar`` shared library is distributed under the
[GNU Lesser General Public License, version 2.1](http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html).
24 changes: 24 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
echo Source wheel
rm -rf build dist MANIFEST.in pyzbar.egg-info
cp MANIFEST.in.all MANIFEST.in
./setup.py bdist_wheel

DLL_ROOT=https://github.com/NaturalHistoryMuseum/barcode-reader-dlls/releases/download/0.1
if [ ! -f pyzbar/libzbar-32.dll ]; then
echo Fetch DLLs
wget $DLL_ROOT/libzbar-32.dll $DLL_ROOT/libiconv-2.dll $DLL_ROOT/libzbar-64.dll $DLL_ROOT/libiconv.dll --directory-prefix pyzbar/
fi

echo Windows 32-bit wheel
rm -rf build pyzbar.egg-info
cat MANIFEST.in.all MANIFEST.in.win32 > MANIFEST.in
./setup.py bdist_wheel --plat-name=win32

echo Windows 32-bit wheel
# Remove these dirs to prevent win32 DLLs from being included in win64 build
rm -rf build pyzbar.egg-info
cat MANIFEST.in.all MANIFEST.in.win64 > MANIFEST.in
./setup.py bdist_wheel --plat-name=win_amd64

echo Clean
rm -rf build MANIFEST.in pyzbar.egg-info

0 comments on commit 64134f4

Please sign in to comment.