# -*- 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-beautifulsoup4
version             4.9.3
revision            1
categories-append   textproc
license             MIT
platforms           darwin
maintainers         nomaintainer
supported_archs     noarch
description         Python HTML/XML parser
long_description    Beautiful Soup is a Python HTML/XML parser designed for \
                    quick turnaround projects like screen-scraping.

checksums           rmd160  825e3830c785519220eab2998eb83f396cae13fd \
                    sha256  84729e322ad1d5b4d25f805bfa05b902dd96450f43842c4e99067d5e1369eb25 \
                    size    376031

homepage            https://www.crummy.com/software/BeautifulSoup/

python.versions     27 35 36 37 38 39

if {${name} ne ${subport}} {
    if {${python.version} < 36} {
        version     4.6.3
        revision    0
        epoch       1

        checksums   rmd160  fc039d0cd41ef5612cdd57fcdfff4b1758a85a1a \
                    sha256  90f8e61121d6ae58362ce3bed8cd997efb00c914eae0ff3d363c32f9a9822d10 \
                    size    167469
    }

    set branch      [join [lrange [split ${version} .] 0 1] .]
    master_sites    https://www.crummy.com/software/BeautifulSoup/bs4/download/${branch}/
    distname        beautifulsoup4-${version}

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

    if {${python.version} > 35} {
        depends_lib-append \
                    port:py${python.version}-soupsieve
    }

    variant html5lib description {Build with HTML5 support} {
        depends_lib-append  port:py${python.version}-html5lib
    }

    variant lxml description {Build with lxml support} {
        depends_lib-append  port:py${python.version}-lxml
    }

    post-destroot   {
        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 644 -W ${worksrcpath} \
            COPYING.txt \
            LICENSE \
            NEWS.txt \
            PKG-INFO \
            README.md \
            ${destroot}${docdir}
    }

    default_variants    +html5lib +lxml

    # Python 3+ needs more commands to test
    if {${python.version} == 27} {
        depends_test-append port:py${python.version}-nose
        test.run            yes
        test.cmd            nosetests-${python.branch}
        test.target         test
        test.env            PYTHONPATH=${worksrcpath}/build/lib
        test.target
    }

    livecheck.type  none
} else {
    livecheck.type      regex
    livecheck.regex     (4\\.\[0-9.\]+)
}
