# -*- 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.10.0
revision            0
epoch               1

categories-append   devel
platforms           {darwin any}
supported_archs     noarch
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  98da16573df62de72533794fe0b0464aac9ef79f \
                    sha256  fa0515697d4c98dbe04d9e898d816de1427e5b9ae5d0e152169109fd21f5d29c \
                    size    2344536

python.versions     39 310 311 312 313

foreach pver {39 310 311 312 313} {
    subport py${pver}-sip-devel {
        version         6.9.2.dev1+ga0d45a97
        master_sites    https://www.riverbankcomputing.com/pypi/packages/snapshots/sip
        epoch           0
        revision        0
        checksums       rmd160  6d76c0a0e7a873426724e599f98e2eff049e6320 \
                        sha256  3c9dba536dbc6f5a5c11b64cb78c07e79c8d3b0168f8428d5ca58e40dcf8c2fd \
                        size    422152
        conflicts       py${pver}-sip
    }

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

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

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

    # 'ScopedName' object has no attribute 'replace'
    patchfiles-append \
                patch-ScopedName-str-conversion.diff

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

    post-destroot {
        xinstall -d ${destroot}${prefix}/share/doc
        xinstall -m 0644 -W ${worksrcpath} LICENSE README.md \
              ${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"
}