# Maintainer: Dominykas Svetikas <archlinux@svetikas.lt>
pkgname=random-file-picker-git
_pkgname=random-file-picker
pkgver=r4.5667833
pkgrel=1
pkgdesc='A tool for picking random files from a directory for viewing.'
arch=('any')
url='https://git.svetikas.lt/JustAnyone/random-file-picker'
license=('MIT')
depends=('python' 'python-requests' 'python-textual')
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-setuptools' 'python-uv' 'git')
conflicts=('random-file-picker')
provides=('random-file-picker')
source=("git+$url.git")
md5sums=('SKIP')

pkgver() {
    cd "$_pkgname"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

build() {
    cd "$_pkgname"
    uv build --wheel --no-build-isolation --python /usr/bin/python3
    # Download the typed-argparse wheel into a vendored directory
    mkdir -p "$srcdir/vendored_wheels"
    pip download "typed-argparse==0.3.1" \
        --dest "$srcdir/vendored_wheels" \
        --no-deps
}

package() {
    cd "$_pkgname"
    python -m installer --destdir="$pkgdir" dist/*.whl
    # Install the vendored wheels into the package directory
    python -m installer --destdir="$pkgdir" "$srcdir/vendored_wheels"/*.whl
}
