summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c9fad63e98eb19994f7da31c5c9cc4a765260c6f (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
# Maintainer: Lumaku <lumaku@mailbox.org>
pkgname=python-k2-git
pkgver=1.17
pkgrel=1
pkgdesc='FSA/FST algorithms, differentiable, with PyTorch compatibility'
arch=('any')
url='https://github.com/k2-fsa/k2'
license=('Apache 2.0')
depends=('python>=3.7' 'python-pytorch' 'python-graphviz' 'cuda')
optdepends=('hip: build with HIP')
makedepends=('git' 'python-setuptools' 'cmake' 'chrpath')
provides=('python-k2')
conflicts=("python-k2")
source=(
    "${pkgname}::git+${url}")
md5sums=(
    'SKIP')


pkgver() {
    cd "${pkgname}"
    # To obtain a version number compatible with PEP 440, the K2_IS_STABLE needs to be set
    export K2_IS_STABLE=1
    printf "%s" "$(python setup.py --version)"
}


build() {
    cd "${pkgname}"
    # For a CPU-only installation of k2, use:
    #   export K2_CMAKE_ARGS="-DK2_WITH_CUDA=OFF -DCMAKE_BUILD_TYPE=Release"
    # For another compiler, use
    #   export LANG=C
    #   export CXX=clang++
    #   export K2_MAKE_ARGS="CXX=clang++"
    python setup.py build
}


package() {
    cd "${pkgname}"
    export PYTHONHASHSEED=0
    python setup.py install --root="$pkgdir" --optimize=1 --skip-build
}


check(){
    cd "${pkgname}"
    # k2 requires the compiled binaries; therefore any check() would only work after package()
    # python -c "import k2; s = '0 1 10 0.1\n0 2 20 0.2\n\n  1 2 30 0.3\n  1 3 -1 0.4\n  2 3 -1 0.5\n  3\n'; fsa = k2.Fsa.from_str(s)"
}