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

pkgname=python-fs
pkgver=2.4.16
pkgrel=4
pkgdesc="Filesystem abstraction layer"
arch=('any')
license=('MIT')
url="https://pypi.python.org/pypi/fs/"
depends=('python-appdirs' 'python-pytz' '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')
sha512sums=('24a50fdbb668916e19ef26b21feb345beb6d734e841435de2bef32672e4f6b8329a44e827b6d3bb878c2522098499dea4915adcfa381b0a3c9e20f8c4f7352bb'
            'e48a2d7756c7a8a7ed776740397579dc79f3f2e6e5f5ec794447e3eeba73a0e94e80f4c43d362c63881d849c14a3723bd8c35bc1318d62d8e438a44f2aadc8fa')

prepare() {
  cd pyfilesystem2-$pkgver
  patch --forward --strip=1 --input=../python-fs-py312-test-fix.patch || true
}

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
}
