# -*- 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-gobject3
set my_name         pygobject
version             3.44.1
revision            0

categories-append   gnome
license             LGPL-2.1+
maintainers         {devans @dbevans} {mascguy @mascguy} openmaintainer
platforms           darwin
description         Python bindings for GObject, version 3

long_description    PyGObject is a Python dynamic module that enables developers to use the \
                    power of GObject, which is part of the GNOME platform.

homepage            https://pygobject.readthedocs.io/
use_xz              yes

checksums           rmd160  6c6eb71defdef6095371bcddc33faf4db4e856e9 \
                    sha256  3c6805d1321be90cc32e648215a562430e0d3d6edcda8f4c5e7a9daffcad5710 \
                    size    559432

python.versions     36 37 38 39 310 311
python.pep517       no

if {${name} ne ${subport}} {
    set branch              [join [lrange [split ${version} .] 0 1] .]
    master_sites            gnome:sources/${my_name}/${branch}/
    distname                ${my_name}-${version}

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

    depends_lib-append      path:lib/pkgconfig/glib-2.0.pc:glib2 \
                            port:libffi \
                            port:py${python.version}-cairo \
                            path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection

    compiler.c_standard     2011

    # https://github.com/Damenly/pygobject/commit/01013b1003bac67061e595cd857be9cf7b69d7fd
    # this patch is designed to work around PyGObject's use of GOI's use of LIBFFI
    patchfiles              patch-pygobject_fix_arm64_closure_exec.diff
    patch.pre_args -p1

    build.target            build_ext
    build.args-append       --inplace

# uses g-ir-scanner, which uses $CC from env
if {${universal_possible} && [variant_isset universal]} {
    foreach arch ${configure.universal_archs} {
        lappend merger_build_env(${arch})  "CC=${configure.cc} -arch ${arch}"
        lappend merger_destroot_env(${arch})  "CC=${configure.cc} -arch ${arch}"
    }
} else {
    build.env-append       "CC=${configure.cc} ${configure.cc_archflags}"
    destroot.env-append    "CC=${configure.cc} ${configure.cc_archflags}"
}

    livecheck.type          none
} else {
    livecheck.type          gnome
    livecheck.name          ${my_name}
}
