# -*- 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-sip
version             6.8.0
revision            0
epoch               1

categories-append   devel
license             {GPL-2 GPL-3 PSF}
maintainers         {michaelld @michaelld} {reneeotten @reneeotten} openmaintainer

description         A Python bindings generator for C/C++ libraries
long_description    SIP is a tool that makes it very easy to create \
                    Python bindings for C and C++ libraries. It was \
                    originally developed to create PyQt, the Python \
                    bindings for the Qt toolkit, but can be used to \
                    create bindings for any C or C++ library.

homepage            https://www.riverbankcomputing.com/software/sip/

checksums           rmd160  746b2cf455a2874ff4da8a4821df3ceb9315583b \
                    sha256  2ed1904820cb661b7207eb1dccfaebec1a5463dcad903ba448ad1945502d089c \
                    size    985563

python.versions     35 36 37 38 39 310 311 312

foreach pver {37 38 39 310 311 312} {
    subport py${pver}-sip-devel {
        version         6.8.1.dev2311302116
        master_sites    https://www.riverbankcomputing.com/pypi/packages/sip
        epoch           0
        revision        0
        checksums       rmd160  295f07e60682763c78dc7823d0a57117e8e114c1 \
                        sha256  64076f1a20fba16726ef3e69b5015aeb1c5526c6d7ec3e83c4516854493e0bc5 \
                        size    1129175
        conflicts       py${pver}-sip
    }

    subport py${pver}-sip {
        conflicts       py${pver}-sip-devel
    }
}

if {${name} ne ${subport}} {
    if {${python.version} == 35} {
        version     5.5.0
        revision    1
        checksums   rmd160  fe56e4f7617fcc8aad3c63e10b19996f58ba44dc \
                    sha256  5d024c419b30fea8a6de8c71a560c7ab0bc3c221fbfb14d55a5b865bd58eaac5 \
                    size    1108126
    } elseif {${python.version} == 36} {
        version     6.5.1
        revision    1
        checksums   rmd160  6dcf12ef1007812e9a2fff0483fbdaf423311282 \
                    sha256  204f0240db8999a749d638a987b351861843e69239b811ec3d1881412c3706a6 \
                    size    1197925
    } else {
        depends_lib-append \
                    port:py${python.version}-ply
        # 'ScopedName' object has no attribute 'replace'
        patchfiles-append \
                    patch-ScopedName-str-conversion.diff
    }

    depends_lib-append \
                    port:py${python.version}-packaging \
                    port:py${python.version}-setuptools

    if {${python.version} < 38} {
        depends_lib-append \
                    port:py${python.version}-importlib-metadata
    }

    if {${python.version} <= 36} {
        depends_lib-append \
                    port:py${python.version}-toml
    } elseif {${python.version} < 311} {
        depends_lib-append \
                    port:py${python.version}-tomli
    }

    post-destroot {
        xinstall -d ${destroot}${prefix}/share/doc
        file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/${subport}
        xinstall -m 0644 -W ${worksrcpath} LICENSE LICENSE-GPL2 LICENSE-GPL3 NEWS README ChangeLog \
            ${destroot}${prefix}/share/doc/${subport}
        system "${python.bin} ${python.libdir}/compileall.py ${destroot}${prefix}"
        system "${python.bin} -O ${python.libdir}/compileall.py ${destroot}${prefix}"
    }

    notes "${subport} is available under a PSF license with one addition: \n
    4. Licensee may not use SIP to generate Python bindings for any C or
       C++ library for which bindings are already provided by Riverbank. \n
GPL-2 or GPL-3 licenses are also available. For details see
${prefix}/share/doc/${subport}/LICENSE \[-GPL2 -GPL3\]\n\n"

    livecheck.type  none
}
