# -*- 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
# $Id: Portfile 106911 2013-06-11 14:40:14Z jmr@macports.org $

PortSystem          1.0
PortGroup           python 1.0
PortGroup           select 1.0

set my_name         nose
name                py-${my_name}
version             1.2.1
revision            1
categories-append   www
license             LGPL-2+
maintainers         akitada mcalhoun 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.

platforms           darwin
supported_archs     noarch

homepage            http://somethingaboutorange.com/mrl/projects/${my_name}
master_sites        http://pypi.python.org/packages/source/n/${my_name}
distname            ${my_name}-${version}

checksums           rmd160  11c3750464769cfc9f6be15b7a0b834c8453db5b \
                    sha256  2171e9202d118d302d5db1decb52dd862b79e2a626ca19653a6914574a6ca7d9

python.versions     24 25 26 27 31 32 33

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

depends_run-append  port:nosetests_select
if {$subport != $name} {
    select.group        nosetests
    select.file         ${filespath}/nosetests${python.version}

    depends_lib     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
    }

    post-destroot {
        if {${python.version} == "24" || ${python.version} == "25"} {
            move ${destroot}${prefix}/share/man/man1/nosetests.1 ${destroot}${prefix}/share/man/man1/nosetests${python.branch}.1
            delete ${destroot}${prefix}/bin/nosetests
        } else {
            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 644 -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
    test.cmd  ${python.bin} setup.py test
}

livecheck.type   regex
livecheck.url    ${master_sites}
livecheck.regex     "${my_name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
