# $Id: Portfile 115387 2014-01-01 06:01:56Z jeremyhu@macports.org $

PortSystem 1.0
PortGroup python 1.0
                
name            py-pysvn
version         1.7.6
revision        3
categories-append     devel
maintainers     blair gmail.com:yunzheng.hu openmaintainer
platforms       darwin
license         Apache-1.1
description     Python Subversion Extension (pysvn)
long_description \
    The pysvn module is a python interface to the Subversion version \
    control system. This API exposes client interfaces for managing a \
    working copy, querying a repository, and synchronizing the two.

homepage        http://pysvn.tigris.org/

master_sites    http://pysvn.barrys-emacs.org/source_kits/
distname        pysvn-${version}
checksums       md5     010a80f0058713209d62e96b20afbde9 \
                sha1    720399815278a0b29a2ea87a09a0d2807d4614e4 \
                rmd160  f6b44e293ec4a94cd610cb8e1f2b711c1aad5aee

python.versions 25 26 27

# TODO: Simplify once MacPorts 2.3 is released
set cxx_stdlibflags {}
if {[info exists configure.cxx_stdlib] && ${configure.cxx_stdlib} ne {} && [string match *clang* ${configure.cxx}]} {
    set cxx_stdlibflags -stdlib=${configure.cxx_stdlib}
}

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

    patchfiles      patch-Source_setup_configure.py.diff

    worksrcdir      ${worksrcdir}/Source

    use_configure   yes
    configure.universal_args-delete --disable-dependency-tracking

    pre-configure {
        system "cd ${worksrcpath} && ${python.bin} setup.py backport"
        reinplace "s|'gcc|'${configure.cc}|g" \
            ${worksrcpath}/setup_configure.py
        reinplace "s|'g\+\+|'${configure.cxx} ${cxx_stdlibflags}|g" \
            ${worksrcpath}/setup_configure.py
    }

    configure.cmd   ${python.bin} setup.py configure
    configure.pre_args
    configure.args  --apr-inc-dir=${prefix}/include/apr-1 \
                    --apu-inc-dir=${prefix}/include/apr-1 \
                    --apr-lib-dir=${prefix}/lib \
                    --svn-root-dir=${prefix}
    configure.universal_args-delete --disable-dependency-tracking

    post-configure {
        reinplace "s|^\t@|\t|" ${worksrcpath}/Makefile
    }

    build.cmd       make
    build.target

    destroot {
        file mkdir ${destroot}${python.pkgd}
        file copy ${worksrcpath}/pysvn ${destroot}${python.pkgd}

        eval file copy [glob ${worksrcpath}/../Examples/*] \
            ${destroot}${prefix}/share/doc/${subport}/examples
        eval file copy [glob ${worksrcpath}/../Docs/*] \
            ${destroot}${prefix}/share/doc/${subport}
    }

    test.run        yes
    test.dir        ${worksrcpath}/../Tests
    test.cmd        make
    test.target

    livecheck.type  none
} else {
    livecheck.type  regex
    livecheck.url   http://pysvn.tigris.org/project_downloads.html
    livecheck.regex >pysvn-(.*?)${extract.suffix}<
}
