# -*- 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-Pillow
version             12.2.0
revision            0
categories-append   devel
license             BSD

python.versions     27 39 310 311 312 313 314

maintainers         {stromnov @stromnov} openmaintainer

description         Python Imaging Library (fork)
long_description    {*}${description}

homepage            https://github.com/python-imaging/Pillow

checksums           rmd160  b023f9828fea661ff2ec10d33df13ae244af2b48 \
                    sha256  a830b1a40919539d07806aa58e1b114df53ddd43213d9c8b75847eee6c0182b5 \
                    size    46987819

if {${name} ne ${subport}} {
    if {${python.version} == 27} {
        conflicts   py${python.version}-pil
        version             6.2.2
        python.pep517       no
        checksums           md5 46cad14f0044a5ac4b2d801271528893 \
                            rmd160 22b39d6d4dff18415340df080e1b598ee204a97e \
                            sha256 db9ff0c251ed066d367f53b64827cc9e18ccea001b986d08c265e53625dab950 \
                            size   37811273

        patchfiles-append   patch-setup.py_v6.2.1.diff

        build.target        build_ext
    } elseif {${python.version} == 39} {
        version             9.5.0
        revision            1
        distname            Pillow-${version}
        patchfiles-append   patch-setup.py_v9.5.0.diff
        checksums           rmd160  15a9b4178db7e5995d94650021cdc58631a15226 \
                            sha256  bf548479d336726d7a0eceb6e767e179fbde37833ae42794602631a070d630f1 \
                            size    50488147

        build.args-append   -C raqm=disable \
                            -C imagequant=disable \
                            -C xcb=disable

        variant raqm description {build with raqm feature} {
            build.args-delete      -C raqm=disable
            depends_lib-append     port:libraqm
        }

        variant x11 {
            build.args-delete      -C xcb=disable
            depends_lib-append     port:xorg-libxcb
        }
    } else {
        distname            pillow-${version}
        patchfiles-append   patch-setup.py.diff patch-ImageQt.py.diff

        build.args-append   -C raqm=disable \
                            -C imagequant=disable \
                            -C xcb=disable

        depends_build-append \
                            port:py${python.version}-pybind11

        variant raqm description {build with raqm feature} {
            build.args-delete      -C raqm=disable
            depends_lib-append     port:libraqm
        }

        variant x11 {
            build.args-delete      -C xcb=disable
            depends_lib-append     port:xorg-libxcb
        }
    }

    depends_build-append \
                        port:py${python.version}-setuptools
    depends_lib-append  port:py${python.version}-tkinter \
                        port:py${python.version}-olefile \
                        port:zlib \
                        path:include/turbojpeg.h:libjpeg-turbo \
                        port:tiff \
                        port:lcms2 \
                        port:webp \
                        port:openjpeg \
                        port:freetype

    post-patch {
        reinplace "s|@prefix@|${prefix}|g" ${worksrcpath}/setup.py
    }

    livecheck.type      none
}
