# Maintainer: David Runge <dave@sleepmap.de>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=quodlibet
pkgver=4.2.1
pkgrel=2
pkgdesc="An audio library tagger, manager and player"
arch=('any')
license=('GPL2')
url="https://github.com/quodlibet/quodlibet"
depends=('gst-plugins-base' 'gst-plugins-good' 'gst-plugins-ugly' 'gtk3'
'python-cairo' 'python-dbus' 'python-feedparser' 'python-gobject'
'python-mutagen')
makedepends=('python-pycodestyle' 'python-sphinx_rtd_theme')
checkdepends=('python-pytest' 'python-xvfbwrapper')
optdepends=('gst-libav: ffmpeg (ASF/WMA) support'
            'gst-plugins-bad: Musepack support'
            'gst-plugins-bad: Audio Pitch/Speed plugin'
            'kakasi: Kana Kanji Simple Inverter plugin'
            'libkeybinder3: Multimedia keys support'
            'python-musicbrainzngs: MusicBrainz Lookup plugin'
            'python-pyinotify: Automatic library update plugin')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/${pkgname}/${pkgname}/archive/release-${pkgver}.tar.gz")
sha512sums=('3817611c887b7c1878ccf852311020ded0a813feec1067f861d1157de6331760166c34992a6e4fe225552ae6ed4472000585fe58a3397faf277ae250f6f3c138')

prepare() {
  mv -v "${pkgname}-release-${pkgver}" "${pkgname}-${pkgver}"
  cd "${pkgname}-${pkgver}/${pkgname}"
  # Fix zsh completions dir
  sed -e 's|vendor-completions|site-functions|' \
      -i gdist/zsh_completions.py
}

build() {
  cd "${pkgname}-${pkgver}"/${pkgname}
  python setup.py build
}

check() {
  cd "${pkgname}-${pkgver}/${pkgname}"
  export PYTHONPATH="build:${PYTHONPATH}"
  # not running useless linter checks
  py.test -k 'not TPEP8 and not TPyFlakes'
}

package() {
  cd "${pkgname}-${pkgver}/${pkgname}"
  python setup.py install --skip-build \
    --optimize=1 \
    --prefix=/usr \
    --root="${pkgdir}"
  install -vDm 644 {README,NEWS} -t "${pkgdir}/usr/share/doc/${pkgname}"
}
