# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

pkgname=breezy
pkgver=3.2.2
pkgrel=9
pkgdesc='A decentralized revision control system with support for Bazaar and Git file formats'
arch=('i686' 'x86_64')
url='https://www.breezy-vcs.org/'
msys2_repository_url="https://github.com/breezy-team/breezy"
msys2_references=(
  "purl: pkg:pypi/breezy"
)
license=('GPL2')
groups=('VCS')
depends=('python-configobj'
         'python-fastimport'
         'python-dulwich'
         'python-patiencediff'
         'python-fastbencode')
makedepends=(
  'python-setuptools'
  'python-build'
  'python-installer'
  'python-devel'
  'gcc'
  'cython'
)
provides=(bzr)
conflicts=(bzr)
replaces=(bzr)
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/breezy-team/breezy/archive/brz-${pkgver}.tar.gz
        '0002-add-msys2-certs-location.patch'
        '0003-remove-unused-broken-import.patch'
        '0004-remove-PyInt_AsUnsignedLongMask.patch')
sha256sums=('5661f2e2348a60db4af9c4c8f417a3da3f0bbc02f7a41ce988baba5e1100f3f1'
            '8f3a1c151c9ceb8b2ace12dc1c80bd123810e2e77a2c784385d5ad039f0bd3bb'
            'a8b9707a9077b3c29e65ee5f89741dc2db92837d10a3041aca3d28032bfe7482'
            'cd0062e8e6eece87af16c847ff85a919d349bb24b1110e8ff629284171774b19')

prepare(){
  cd "${srcdir}/${pkgname}-brz-${pkgver}"

  patch -p1 -i ${srcdir}/0002-add-msys2-certs-location.patch
  patch -p1 -i ${srcdir}/0003-remove-unused-broken-import.patch
  # cython 3.1 compatibility
  patch -p1 -i ${srcdir}/0004-remove-PyInt_AsUnsignedLongMask.patch
}

build() {
  cd "${srcdir}/${pkgname}-brz-${pkgver}"

  python -m build --wheel --no-isolation
}

package() {
  cd "${srcdir}/${pkgname}-brz-${pkgver}"

  python -m installer --destdir="$pkgdir" dist/*.whl
  cp "${pkgdir}"/usr/bin/brz "${pkgdir}"/usr/bin/bzr
}
