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

PortSystem          1.0
PortGroup           github 1.0
PortGroup           python 1.0
PortGroup           select 1.0

github.setup        tmux-python tmuxp 1.64.0 v
github.tarball_from archive
name                py-tmuxp
revision            0

categories-append   devel
license             MIT
supported_archs     noarch
platforms           {darwin any}

maintainers         {@egorenar posteo.net:egorenar-dev} \
                    {@judaew judaew} openmaintainer

description         tmux session manager.
long_description    {*}${description}

python.versions     310 311 312 313 314
python.pep517       yes
python.pep517_backend hatch

if {${name} ne ${subport}} {
    depends_lib-append \
                    port:py${python.version}-click \
                    port:py${python.version}-colorama \
                    port:py${python.version}-kaptan \
                    port:py${python.version}-libtmux

    depends_run-append \
                    port:tmuxp_select

    checksums       rmd160  213d8079a513c738fb9c66ff2ddea1704910e5f4 \
                    sha256  e07d25d46b30ea005a2b0b0f3a3a99097ea7a3117e6f9d8b2fd497ddf8a1327c \
                    size    1057733

    select.group    tmuxp
    select.file     ${worksrcpath}/py${python.version}-tmuxp

    post-extract {
        copy -force ${filespath}/tmuxp ${worksrcpath}/py${python.version}-tmuxp
    }

    post-patch {
        reinplace \
            "s,@PYTHON_BRANCH@,${python.branch},g" \
             ${worksrcpath}/${subport}
    }

    post-destroot {
        xinstall -d ${destroot}${prefix}/share/examples/${subport}
        xinstall -m 0644 {*}[glob ${worksrcpath}/examples/*] \
            ${destroot}${prefix}/share/examples/${subport}
    }

    notes "
To make the Python ${python.branch} version of tmuxp the one that is run when\
you execute the commands without a version suffix, e.g. 'tmuxp', run:

port select --set ${select.group} [file tail ${select.file}]
"

    livecheck.type      none
}

github.livecheck.regex  "(\\d+(?:\\.\\d+)+)"
