summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a84ed02c7bc2da92ef9a2a408503c83142c373d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Contributor: Patrick Northon <northon_patrick3@yahoo.ca>
# Contributor: Lukas Jirkovsky <l.jirkovsky@gmail.com>

_pkgname=ocropy
pkgname=${_pkgname}-git
pkgver=998.fe78a04
pkgrel=1
pkgdesc="Python-based OCR package using recurrent neural networks (formerly ocropus)"
arch=('any')
url="https://github.com/ocropus/${_pkgname}"
license=('APACHE')
depends=('python2-imaging' 'python2-scipy' 'python2-matplotlib' 'python2-pytables'
         'imagemagick' 'opencv' 'python2-lxml')
makedepends=('git')
provides=("${_pkgname}")
conflicts=("${_pkgname}")
source=("git+https://github.com/ocropus/${_pkgname}.git"
        "https://github.com/zuphilip/ocropy-models/raw/master/en-default.pyrnn.gz")
sha256sums=('SKIP'
            'b749ec701a53915183963c3814a288de7da5a38261bd9008e0ae0674c71cd1f7')

pkgver() {
  cd "$srcdir/${_pkgname}"
  echo $(git rev-list --count master).$(git rev-parse --short master)
}

prepare() {
  cd "$srcdir/${_pkgname}"
  cp "$srcdir/en-default.pyrnn.gz" models
  
  #sed -i 's|numpy.fromstring|numpy.frombytes|' ocrolib/common.py
  #sed -i 's|tostring|tobytes|' ocrolib/common.py
  #sed -i 's|im.tobytes()|im.tostring()|' 'ocrolib/common.py'
  #sed -i 's|PIL\.Image\.fromstring|PIL\.Image\.frombytes|' 'ocrolib/common.py'
  sed -i 's|tobytes|tostring|' ocrolib/common.py
}

build() {
  cd "$srcdir/${_pkgname}"

  # make sure python2 is always used
  find . -type f -name "*.py" -exec sed -i 's|^#!.*python$|&2|' '{}' ';'
  sed -i 's|^#!.*python$|&2|' ocropus-*
  # FIX LOADING OF MODELS
  sed -i 's|/usr/local|/usr|' ocrolib/common.py
  sed -i 's|/usr/local|/usr|' ocrolib/default.py
  # build
  python2 setup.py build
}

package() {
  cd "$srcdir/${_pkgname}"

  python2 setup.py install --root="$pkgdir/" --optimize=1
}

# vim:set ts=2 sw=2 et: