# -*- 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.3.0
revision            0
categories-append   devel
license             BSD

python.versions     27 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  1371c731efe856275fa0efd5c8f6b7469ca711c2 \
                    sha256  3b8182a766685eaa002637e28b4ec8d6b18819a0c71f579bf0dbaa5830297cce \
                    size    47025035

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
    } 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:libavif \
                        port:lcms2 \
                        port:webp \
                        port:openjpeg \
                        port:freetype

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

    livecheck.type      none
}
