# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Cravix <dr.neemous@gmail.com>

pkgbase=python-pygame-sdl2
pkgname=(
  python-pygame-sdl2
  python2-pygame-sdl2
)
pkgver=2.1.0.r399.5777335
pkgrel=1
epoch=1
pkgdesc='Reimplementation of portions of the pygame API using SDL2'
arch=(x86_64)
url=https://github.com/renpy/pygame_sdl2
license=(
  LGPL2.1
  zlib
)
depends=(
  sdl2_image
  sdl2_mixer
  sdl2_ttf
)
makedepends=(
  cython
  cython2
  git
  python
  python-setuptools
  python2
  python2-setuptools
)
_commit=5777335c4613bddf9dd51abd58d8dfa2a9a6568e
source=(
  git+https://github.com/renpy/pygame_sdl2.git#commit=${_commit}
  python-pygame-sdl2-cython2.patch
)
b2sums=(
  SKIP
  0d17bd3c850877dce3acd2844aabf7661ded58c494be4fcc59046a124e367efec286e314fc4319ed719d7b7691296f0ade9cbf194fde31e136a3a850dc2868ce
)

prepare() {
  cp -r pygame_sdl2 python2-pygame_sdl2
  mv pygame_sdl2 python-pygame_sdl2

  cd python2-pygame_sdl2
  patch -Np1 -i ../python-pygame-sdl2-cython2.patch
}

pkgver() {
  cd python-pygame_sdl2
  version="$(cat src/pygame_sdl2/version.py | grep '^vernum = ' | sed 's/^vernum = //; s/(//; s/)//; s/, /./g')"
  echo "${version}.r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
}

build() {
  for p in python{,2}; do
    pushd $p-pygame_sdl2
    $p setup.py build
    popd
  done
}

package_python-pygame-sdl2() {
  depends+=(python)

  cd python-pygame_sdl2

  python setup.py install --root="${pkgdir}" --prefix=/usr --optimize=1 --skip-build
  install -Dm 644 COPYING.ZLIB -t "${pkgdir}"/usr/share/licenses/python-pygame-sdl2/
}

package_python2-pygame-sdl2() {
  depends+=(python2)

  cd python2-pygame_sdl2

  python2 setup.py install --root="${pkgdir}" --prefix=/usr --optimize=1 --skip-build
  install -Dm 644 COPYING.ZLIB -t "${pkgdir}"/usr/share/licenses/python2-pygame-sdl2/
}

# vim: ts=2 sw=2 et:
