# -*- 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           select 1.0

name                py-nose
version             1.3.7
revision            3

categories-append   www
license             LGPL-2+
maintainers         {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description         A Python unittest extension.
long_description \
    A unittest extension offering automatic test \
    suite discovery, simplified test authoring, \
    and output capture. Nose provides an alternate \
    test discovery and running process for \
    unittest, one that is intended to mimic the \
    behavior of py.test as much as is reasonably \
    possible without resorting to magic.

supported_archs     noarch
platforms           {darwin any}

homepage            https://nose.readthedocs.io/

checksums           rmd160  4a3e1bb3121a2620aec0baa51eac1bb5a11cf6e9 \
                    sha256  f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98 \
                    size    280488

python.versions     27 35 36 37 38 39 310 311 312 313

# already installs version-suffixed executables
python.link_binaries no
python.move_binaries no

depends_run-append  port:nosetests_select

if {${name} ne ${subport}} {
    select.group        nosetests
    select.file         ${filespath}/nosetests${python.version}

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

    post-patch {
        reinplace "s|man/man|share/man/man|" ${worksrcpath}/setup.py

        # One of the tests fails if this directory does not exist
        file mkdir ${worksrcpath}/functional_tests/support/empty
    }

    if {${python.version} >= 36 && ${python.version} < 313} {
        patchfiles-append   no_2to3.diff

        post-patch {
            system -W ${worksrcpath} "${prefix}/bin/2to3-${python.branch} --write --nobackups nose"
        }
    }

    post-destroot {
        ln -s ${python.prefix}/bin/nosetests-${python.branch} ${destroot}${prefix}/bin/
        ln -s ${python.prefix}/share/man/man1/nosetests.1 ${destroot}${prefix}/share/man/man1/nosetests${python.branch}.1

        xinstall -m 0644 -W ${worksrcpath} \
            AUTHORS CHANGELOG NEWS README.txt \
            ${destroot}${prefix}/share/doc/${subport}

        file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/${subport}/html

        file delete ${destroot}${prefix}/share/doc/${subport}/examples
        file copy ${worksrcpath}/examples ${destroot}${prefix}/share/doc/${subport}
    }

    test.run  yes
}
