# Maintainer: Andrea Manenti # Contributor: Henry-ZHR pkgname=python-safetensors pkgver=0.4.3 pkgrel=2 pkgdesc='Simple, safe way to store and distribute tensors' arch=('x86_64') url='https://github.com/huggingface/safetensors' license=('Apache') depends=('python') makedepends=('python-build' 'python-installer' 'python-maturin' 'python-wheel' 'python-setuptools-rust') optdepends=('python-jax' 'python-flax' 'python-jaxlib' 'python-numpy' 'python-paddlepaddle' 'python-tensorflow' 'python-pytorch') checkdepends=('python-pytorch' 'python-numpy' 'python-tensorflow' 'python-jax' 'python-flax' 'python-jaxlib' # 'python-paddlepaddle' 'python-black' 'python-isort' 'flake8' 'python-click' 'python-huggingface-hub' 'python-pytest' 'python-pytest-benchmark' 'python-h5py') source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz") sha512sums=('278469d7bc8a4285519cf8020891d0f0e107d8124ad2c24686ca8a19ef2f210c49d9483c502bd5aa5d73940a775ac3eb5e3b90f62825dd7845c351bbdc8c82c3') prepare() { mkdir -p "safetensors-${pkgver}/.git" } build() { cd "safetensors-${pkgver}/bindings/python" export RUSTUP_TOOLCHAIN=stable python -m build --wheel --no-isolation } check() { cd "safetensors-${pkgver}/bindings/python" local python_version=$(python -V | sed -e 's/Python \([0-9]\.[0-9]\+\)\..*/\1/') mkdir "${PWD}/test_build" python -m installer --destdir="${PWD}/test_build" dist/*.whl PYTHONPATH="${PWD}/test_build/usr/lib/python${python_version}/site-packages" pytest tests/ \ --ignore=tests/test_paddle_comparison.py # No working paddlepaddle package, disable it temporarily } package() { cd "safetensors-${pkgver}/bindings/python" python -m installer --destdir="${pkgdir}" dist/*.whl }