# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           python 1.0

name                py-gguf
version             0.19.0
revision            0
categories-append   llm
license             MIT
maintainers         {i0ntempest @i0ntempest} openmaintainer
platforms           {darwin any}
supported_archs     noarch

description         Python library for writing binary files in the GGUF (GGML Universal File) format
long_description    {*}${description}
homepage            https://ggml.ai

checksums           rmd160  5d635959bd1c2add2848bc1fc989ba64d677be96 \
                    sha256  dbadcd6cc7ccd44256f2229fe7c2dff5e8aa5cf0612ab987fd2b1a57e428923f \
                    size    111220

python.versions     313 314

# potentially needed if switching to github later (sync with llama.cpp)
# and the livecheck block below
#python.pep517_backend
#set build_folder    gguf-py
#build.dir           ${worksrcpath}/${build_folder}

if {${name} ne ${subport}} {
    depends_build-append \
                    port:py${python.version}-poetry-core

    depends_lib-append \
                    port:py${python.version}-numpy \
                    port:py${python.version}-tqdm \
                    port:py${python.version}-yaml \
                    port:py${python.version}-sentencepiece \
                    port:py${python.version}-requests

    livecheck.type  none

    post-destroot {
        if {![variant_isset gui]} {
            delete ${destroot}${python.prefix}/bin/gguf-editor-gui
            delete ${destroot}${prefix}/bin/gguf-editor-gui-${python.branch}
        }
    }

    variant gui description {install the Qt-based gguf-editor-gui script} {
        depends_run-append  \
                    port:py${python.version}-pyside6
    }
}

#livecheck.version   ${version}
#livecheck.url       https://raw.githubusercontent.com/${github.author}/${github.project}/refs/heads/master/${build_folder}/pyproject.toml
#livecheck.regex     {version\s*=\s*["'](\d+(?:\.\d+)*)["']}

notes "
    ${subport} port installs the version on PyPI. For gauranteed compatibility with llama.cpp,\
    install llama.cpp +model_converters and use ${prefix}/libexec/llama.cpp/gguf-py.
"
