summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 92d85e973aeef8178d87b3047a11f1e2e62a884f (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
58
59
60
61
62
63
64
65
66
67
68
69
70
# Maintainer: Daniel Bermond < yahoo-com: danielbermond >

_srcname=vmaf
_sureal_commit='4d0fee6e83047da53ff1776a883579bfe101e8ea'

pkgname=python2-vmaf
pkgver=1.3.9
pkgrel=1
pkgdesc='Perceptual video quality assessment algorithm based on multi-method fusion (python2 implementation)'
arch=('any')
url='https://github.com/netflix/vmaf/'
license=('APACHE')
depends=(
    # official repositories:
        'python2' 'python2-numpy' 'python2-scipy' 'python2-matplotlib'
        'python2-pandas' 'python2-scikit-learn' 'python2-h5py'
    # AUR:
        'python2-scikit-image'
)
makedepends=('git' 'python2-setuptools')
conflicts=('python2-vmaf-git')
source=("${_srcname}-${pkgver}.tar.gz"::"https://github.com/Netflix/${_srcname}/archive/v${pkgver}.tar.gz"
        'vmaf-submodule-sureal'::"git+https://github.com/Netflix/sureal.git#commit=${_sureal_commit}")
sha256sums=('c9e4fc850f66cf959a36c9603cef26c4298eec20d6c26f9482a355c5753c092d'
            'SKIP')

prepare() {
    cd "${_srcname}-${pkgver}"
    
    rm -rf sureal
    ln -sf "${srcdir}/vmaf-submodule-sureal" sureal
}

build() {
    msg2 'Building for Python2...'
    cd "${_srcname}-${pkgver}/python"
    python2 setup.py build
}

# waiting for upstream to finish python3 support
# https://github.com/Netflix/vmaf/issues/128
# https://github.com/Netflix/vmaf/blob/a0a4deeb7cd7b6e5cdd7c40398e6ce3c1498a0d8/resource/doc/VMAF_Python_library.md

package() {
    cd "${_srcname}-${pkgver}/python"
    
    python2 setup.py install --root="$pkgdir" --optimize='1'
    
    # vmaf python2 executables
    cd script
    local _executables=($(find . -type f -executable))
    for _script in ${_executables[@]}
    do
        install -D -m755 "$_script" -t "${pkgdir}/usr/bin"
    done
    
    # sureal python2 executable
    cd "${srcdir}/${_srcname}-${pkgver}/sureal/python/script"
    install -D -m755 run_subj.py -t "${pkgdir}/usr/bin"
    
    # sureal python2 modules
    cd "${srcdir}/${_srcname}-${pkgver}/sureal/python/src"
    cp -af sureal "${pkgdir}/usr/lib/python2.7/site-packages"
    
    # fix shebang on python2 scripts
    for _script in "$pkgdir"/usr/bin/*
    do
        sed -i '1s/python$/python2/' "$_script"
    done
}