if ab_match_arch loongarch64; then
    abinfo "Syncing Python releases from loong64/versions ..."
    python3 "$SRCDIR"/crates/uv-python/fetch-download-metadata.py
fi

abinfo "Building uv ..."
export tripple="$(rustc --print host-tuple)"
maturin build --locked --release --target "$tripple" --strip --compatibility linux
maturin build --locked --release --target "$tripple" --strip --compatibility linux -m crates/uv-build/Cargo.toml

abinfo "Installing uv ..."
python3 -m installer "$SRCDIR"/target/wheels/uv-*.whl --destdir "$PKGDIR"
python3 -m installer "$SRCDIR"/target/wheels/uv_build-*.whl --destdir "$PKGDIR"

abinfo "Installing shell completions ..."
for command in uv uvx
do
    "$PKGDIR"/usr/bin/"$command" --generate-shell-completion bash > "$SRCDIR"/"$command".bash
    "$PKGDIR"/usr/bin/"$command" --generate-shell-completion fish > "$SRCDIR"/"$command".fish
    "$PKGDIR"/usr/bin/"$command" --generate-shell-completion zsh > "$SRCDIR"/_"$command"

    install -Dm0644 "$command".bash -t "$PKGDIR"/usr/share/bash-completion/completions/
    install -Dm0644 "$command".fish -t "$PKGDIR"/usr/share/fish/vendor_completions.d/
    install -Dm0644 _"$command" -t "$PKGDIR"/usr/share/zsh/site-functions/
done
