# -*- 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
PortGroup           github 1.0

github.setup        ronaldoussoren pyobjc 7.1 v
revision            0

checksums           rmd160  f2d5035a5f35f12a6b34861c0a15a9446bd514fa \
                    sha256  ba15cfd3d3e1d809b236fe147c0854c55cdfed14b7580f1651d9651a4760fdfc \
                    size    12861424

name                py-pyobjc
categories-append   devel
license             MIT
maintainers         openmaintainer {danchr @danchr}
platforms           darwin
description         bidirectional bridge between python and Objective C
long_description    The PyObjC project aims to provide a bridge between \
                    the Python and Objective-C programming languages. The \
                    bridge is intended to be fully bidirectional, allowing \
                    the Python programmer to take full advantage of the \
                    power provided by various Objective-C based toolkits \
                    and the Objective-C programmer transparent access to \
                    Python based functionality.
homepage            https://pyobjc.readthedocs.io

python.versions     36 37 38 39

if {${name} ne ${subport}} {
    depends_lib-append \
                    port:libffi \
                    port:py${python.version}-setuptools
    depends_build   port:py${python.version}-sphinx

    # the patches below suppresses cleaning on incremental builds, as
    # MacPorts handles that itself, and disables a sphinx extension
    # not in MacPorts
    patchfiles-append \
                    patch-docs-conf.py.diff \
                    patch-install.py.diff

    post-patch {
        reinplace \
            "s/sphinx-build /sphinx-build-${python.branch} /g" \
            ${worksrcpath}/docs/Makefile
    }

    if {${configure.sdkroot} eq ""} {
        set sdkroot "/"
    } else {
        set sdkroot ${configure.sdkroot}
    }

    build.env-append    SDKROOT=${sdkroot}
    destroot.env-append SDKROOT=${sdkroot}

    platform darwin 8 {
        depends_lib
        pre-fetch {
            ui_error "${subport} @${version} requires Mac OS X 10.5 or later"
            return -code error "incompatible Mac OS X version"
        }
    }

    # the pyobjc build system is vaguely horrible, so do everything in
    # the destroot target
    build {
        system -W ${worksrcpath}/docs "make html"
    }

    # don't pass --no-user-cfg, as the build system subclasses the
    # install command from distutils, not setuptools -- in fact, doing
    # so breaks the build...
    destroot.cmd "${python.bin} install.py"

    post-destroot {
        xinstall -m 644 -W ${worksrcpath}/pyobjc-core HISTORIC.txt Install.txt \
            License.txt README.txt \
            ${destroot}${prefix}/share/doc/${subport}
        copy ${worksrcpath}/docs/_build/html ${destroot}${prefix}/share/doc/${subport}/html
    }
}
