# -*- 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-psutil
version             7.2.2
revision            0
categories-append   devel sysutils
license             MIT
maintainers         {stromnov @stromnov} openmaintainer

description         Process utilities module for Python
long_description    psutil is a module providing an interface for retrieving \
                    information on all running processes and system \
                    utilization (CPU, disk, memory) in a portable way \
                    by using Python, implementing many functionalities \
                    offered by command line tools such as: ps, top, df, \
                    kill, free, lsof, free, netstat, ifconfig, nice, ionice, \
                    iostato, iotop, uptime, tty.

homepage            https://github.com/giampaolo/psutil
checksums           rmd160  86a4fa5f20038cdbd34621c91ee0455ed8fd82c4 \
                    sha256  0746f5f8d406af344fd547f1c8daa5f5c33dbc293bb8d6a16d80b4bb88f59372 \
                    size    493740

python.versions     27 310 311 312 313 314

# TODO: see if the code can be improved for legacy systems and PowerPC.
# Likely something is still missing, though it works now.

if {${subport} ne ${name}} {
    if {${python.version} == 27} {
        version     6.1.1
        revision    0
        checksums   rmd160  87793f2406bfc5f2364d50ae0d78b03d8b87b6d7 \
                    sha256  cf8496728c18f2d0b45198f06895be52f36611711746b7f30c464b422b50e2f5 \
                    size    508502
    } else {
        PortGroup   legacysupport 1.1

        # strnlen
        legacysupport.newest_darwin_requires_legacy 10

        # psutil/arch/osx/cpu.c:308: error: ‘for’ loop initial declaration used outside C99 mode
        if {${python.version} < 313} {
            configure.cflags-append \
                    -std=c99
        }

        # This is needed, PG itself fails to pass flags:
        if {${os.platform} eq "darwin" && ${os.major} < 11} {
            build.cmd-prepend \
                    CFLAGS='${configure.cflags} -isystem${prefix}/include/LegacySupport' \
                    LDFLAGS='${configure.ldflags} -lMacportsLegacySupport'
        }

        # Fix some incorrect macros:
        patchfiles-append \
                    patch-fix-Availability.diff \
                    patch-ppc.diff

        # https://github.com/giampaolo/psutil/issues/2694
        patchfiles-append \
                    patch-fix-type-32-bit.diff
    }

    livecheck.type  none
}
