# -*- Mode: Tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup python 1.0

# Please keep the version of the libxml2 and py-libxml2 ports the same.

name                    py-libxml2
version                 2.9.7
categories-append       textproc
license                 MIT
platforms               darwin
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description             Python bindings for libxml2
long_description        ${description}

homepage                http://xmlsoft.org/python.html

master_sites            http://www.xmlsoft.org/sources/ \
                        ftp://gd.tuwien.ac.at/pub/libxml/ \
                        ftp://xmlsoft.org/libxml2/

distname                libxml2-${version}
dist_subdir             libxml2

checksums               rmd160  f596599cbcac6d3175482177c3320a56e68b49a2 \
                        sha256  f63c5e7d30362ed28b38bfa1ac6313f9a80230720b7fb6c80575eeab3ff5900c

python.versions         27 34 35 36

if {${name} ne ${subport}} {
    depends_lib-append      port:libxml2

    worksrcdir              ${worksrcdir}/python

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

    # Note: the latter patch is adapted from Fedora,
    # https://src.fedoraproject.org/cgit/rpms/libxml2.git/tree/libxml2-2.9.4-remove-pyverify_fd.patch
    patchfiles              patch-setup.py.diff \
                            libxml2-2.9.4-remove-pyverify_fd.patch

    post-destroot {
      set docdir ${prefix}/share/doc/${subport}
      xinstall -d ${destroot}${docdir}
      xinstall -m 644 -W ${worksrcpath} README TODO \
        ${destroot}${docdir}
    }
}

livecheck.type  regex
livecheck.url   http://www.xmlsoft.org/news.html
livecheck.regex {<h3>[v]*(\d+(?:\.\d+)*): .*</h3>}