# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-fs
pkgver=2.4.16
pkgrel=5
pkgdesc="Filesystem abstraction layer"
arch=('any')
license=('MIT')
url="https://pypi.python.org/pypi/fs/"
depends=('python' 'python-appdirs' 'python-setuptools' 'python-six')
makedepends=('python-build' 'python-installer' 'python-wheel')
checkdepends=('python-pytest' 'fuse2' 'python-pyftpdlib' 'python-psutil'
              'python-parameterized')
source=("https://github.com/PyFilesystem/pyfilesystem2/archive/v$pkgver/$pkgname-$pkgver.tar.gz"
        'python-fs-py312-test-fix.patch::https://github.com/PyFilesystem/pyfilesystem2/pull/570.patch'
        'fix-pyftpdlib-compatibility.patch')
sha512sums=('24a50fdbb668916e19ef26b21feb345beb6d734e841435de2bef32672e4f6b8329a44e827b6d3bb878c2522098499dea4915adcfa381b0a3c9e20f8c4f7352bb'
            'e48a2d7756c7a8a7ed776740397579dc79f3f2e6e5f5ec794447e3eeba73a0e94e80f4c43d362c63881d849c14a3723bd8c35bc1318d62d8e438a44f2aadc8fa'
            '9359eeb2dede3344917fa3756caa0c72a20bc2cfcd2ced46666b5cb3cd014330f83cc9e5c11e3c14b0a793d9aca862121a7c4874f02c257f3312d145860933bc')

prepare() {
  cd pyfilesystem2-$pkgver
  patch --forward --strip=1 --fuzz=3 --input=../python-fs-py312-test-fix.patch
  patch --forward --strip=1 --input=../fix-pyftpdlib-compatibility.patch
}

build() {
  cd pyfilesystem2-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd pyfilesystem2-$pkgver
  # TestFTPFS needs to be updated to use the asyncio module
  PYTHONPATH="$PWD" pytest --deselect tests/test_ftpfs.py::TestFTPFS
}

package() {
  cd pyfilesystem2-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
