# -*- 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           active_variants 1.1
PortGroup           python 1.0

name                maigret
version             0.6.2
revision            0

license             MIT
maintainers         {mps @Schamschula} openmaintainer
description         Maigret collects a dossier on a person by username only, checking \
                    for accounts on a huge number of sites and gathering all the \
                    available information from web pages.
long_description    {*}${description} No API keys required. Maigret is an easy-to-use \
                    and powerful fork of Sherlock.
homepage            https://github.com/soxoj/maigret

supported_archs     noarch
platforms           {darwin any}

checksums           rmd160  3a1a27f2a54389cf99463b6be65e73cbac668de2 \
                    sha256  d731f2aa9be8bc83fa2743ae7e39469cd2bfe9cbfd5f7bcbceaa3c00ebe54736 \
                    size    274042

variant python310 conflicts python311 python312 python313 python314 description {Use Python 3.10} {}
variant python311 conflicts python310 python312 python313 python314 description {Use Python 3.11} {}
variant python312 conflicts python310 python311 python313 python314 description {Use Python 3.12} {}
variant python313 conflicts python310 python311 python312 python314 description {Use Python 3.13} {}
variant python314 conflicts python310 python311 python312 python313 description {Use Python 3.14} {}

if {![variant_isset python310] && ![variant_isset python311] \
    && ![variant_isset python312] && ![variant_isset python313]} {
        default_variants +python314
}

foreach pv {314 313 312 311 310} {
    if {[variant_isset python${pv}]} {
        python.default_version ${pv}
        set python.branch [string index ${python.version} 0].[string range ${python.version} 1 end]
        break
    }
}

python.pep517_backend \
                    poetry

depends_lib-append  \
                    port:py${python.version}-aiodns \
                    port:py${python.version}-aiohttp \
                    port:py${python.version}-aiohttp-socks \
                    port:py${python.version}-alive-progress \
                    port:py${python.version}-arabic-reshaper \
                    port:py${python.version}-async-timeout \
                    port:py${python.version}-attrs \
                    port:py${python.version}-bidi \
                    port:py${python.version}-certifi \
                    port:py${python.version}-chardet \
                    port:py${python.version}-cloudscraper \
                    port:py${python.version}-colorama \
                    port:py${python.version}-country \
                    port:py${python.version}-curl-cffi \
                    port:py${python.version}-flask \
                    port:py${python.version}-future \
                    port:py${python.version}-html5lib \
                    port:py${python.version}-idna \
                    port:py${python.version}-jinja2 \
                    port:py${python.version}-lxml \
                    port:py${python.version}-markupsafe \
                    port:py${python.version}-mock \
                    port:py${python.version}-multidict \
                    port:py${python.version}-networkx \
                    port:py${python.version}-platformdirs \
                    port:py${python.version}-pypdf \
                    port:py${python.version}-pyvis \
                    port:py${python.version}-requests \
                    port:py${python.version}-requests-futures \
                    port:py${python.version}-requests-toolbelt \
                    port:py${python.version}-reportlab \
                    port:py${python.version}-socid-extractor \
                    port:py${python.version}-six \
                    port:py${python.version}-socks \
                    port:py${python.version}-soupsieve \
                    port:py${python.version}-stem \
                    port:py${python.version}-torrequest \
                    port:py${python.version}-typing_extensions \
                    port:py${python.version}-webencodings \
                    port:py${python.version}-xhtml2pdf \
                    port:py${python.version}-xmind \
                    port:py${python.version}-yarl

require_active_variants \
                    py${python.version}-flask    async

post-destroot {
    xinstall -d ${destroot}${prefix}/var/${name}
    move ${destroot}${python.prefix}/lib/python${python.branch}/site-packages/${name}/resources/data.json \
        ${destroot}${prefix}/var/${name}/data.json.dist
}

post-activate {
    if { [file exists ${prefix}/var/maigret/data.json] == 0 } {
         xinstall -m 666 ${prefix}/var/${name}/data.json.dist ${prefix}/var/${name}/data.json
         ln -s ${prefix}/var/maigret/data.json \
             ${python.prefix}/lib/python${python.branch}/site-packages/${name}/resources/data.json
    }
}
