# -*- 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-curl-cffi
python.rootname     curl_cffi
version             0.16.0
revision            1

license             MIT
maintainers         {mps @Schamschula} openmaintainer
description         Python binding for curl-impersonate fork via cffi.
long_description    {*}${description}
homepage            https://github.com/lexiforest/curl_cffi

master_sites        ${homepage}/releases/download/v${version}/

distname            ${python.rootname}-${version}

checksums           rmd160  31dbfe700f3d028976b4e3faf248b89f3a3ebd2e \
                    sha256  b00b423da8028eb6221e3b63bcd63d681150c07cee8b16000d1f7ea292731895 \
                    size    238344

universal_variant   no

python.versions     310 311 312 313 314

if {${name} ne ${subport}} {
    patchfiles      patch-scripts-build.py.diff \
                    patch-libs.json \
                    macports-curl-impersonate.patch

    post-patch {
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/scripts/build.py
        if {${configure.cxx_stdlib} eq "libc++"} {
            reinplace "s|@CXXLIB@|c++|g" ${worksrcpath}/scripts/build.py
        } else {
            reinplace "s|@CXXLIB@|stdc++|g" ${worksrcpath}/scripts/build.py
        }
    }

    depends_lib-append \
                    port:curl-impersonate \
                    port:py${python.version}-certifi \
                    port:py${python.version}-cffi
    depends_run-append \
                    port:py${python.version}-rich
}
