# -*- 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 115940 2014-01-14 21:49:11Z stromnov@macports.org $

PortSystem          1.0
PortGroup           python 1.0

name                py-backports-lzma
version             0.0.2
revision            0
categories-append   devel
platforms           darwin
license             BSD
supported_archs     noarch

python.versions     27

maintainers         stromnov openmaintainer

description         Backport of Python 3.3's 'lzma' module for XZ/LZMA compressed files.
long_description    ${description}

homepage            https://github.com/peterjc/backports.lzma
master_sites        https://pypi.python.org/packages/source/b/backports.lzma/

distname            backports.lzma-${version}

checksums           rmd160  2634df890548dc7213cd686d3f835154f557f96c \
                    sha256  a0966deeb2533e96ea84dc0fb7948aa23421c7f061197133b62665a52dfa64e6

if {${name} ne ${subport}} {
    depends_lib-append  port:py${python.version}-backports \
                        port:xz

    patchfiles-append   patch-setup.py.diff

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

    post-destroot {
        foreach f {__init__.py __init__.pyc __init__.pyo __pycache__} {
            set fp "${destroot}${python.pkgd}/backports/$f"
            if {[file exists ${fp}]} {
                file delete -force ${fp}
            }
        }
    }

    livecheck.type      none
} else {
    livecheck.type      regex
    livecheck.url       ${master_sites}
    livecheck.regex     {backports\.lzma-(\d+(?:\.\d+)*)\.[tz]}
}
