# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 86432 2011-10-25 18:27:15Z devans@macports.org $

PortSystem 1.0
PortGroup  python26 1.0

name                    py26-openssl
version                 0.10
revision        1
license                 LGPL-2.1
categories              python devel security
maintainers             mcalhoun openmaintainer
platforms               darwin freebsd
description             python wrapper around the OpenSSL library
long_description        This python module is a rather thin wrapper around (a \
                                subset of) the OpenSSL library. With thin wrapper a lot of the \
                                object methods do nothing more than calling a corresponding \
                                function in the OpenSSL library.

homepage                http://launchpad.net/pyopenssl
master_sites            http://pypi.python.org/packages/source/p/pyOpenSSL/
distname                pyOpenSSL-${version}

checksums               md5     34db8056ec53ce80c7f5fc58bee9f093 \
                        sha1    11c956d317ab2b1628937a2681acc31f4b890fe8 \
                        rmd160  1e303655754b5652327151a790ac6f3b25959972

depends_lib-append port:openssl

post-patch {
    reinplace "s|#!/usr/bin/env python|#!${prefix}/bin/python2.6|g" ${worksrcpath}/examples/proxy.py
}

post-destroot {
    xinstall -m 644 -W ${worksrcpath} \
        COPYING ChangeLog INSTALL README TODO \
        ${destroot}${prefix}/share/doc/${name}
    
    file delete ${destroot}${prefix}/share/doc/${name}/examples
    file copy ${worksrcpath}/examples ${destroot}${prefix}/share/doc/${name}
}

variant doc description {build html documentation} {
    depends_build-append port:latex2html
    
    post-patch {
        # Ensure that the correct binaries are used.
        # Some are not actually invoked because only the html documentation is created.
        foreach bin {bibtex dvips latex latex2html lynx makeindex pdflatex perl python} {
            reinplace "s| = \"${bin}\"| = \"${prefix}/bin/${bin}\"|g" ${worksrcpath}/doc/tools/mkhowto
        }
        
        # Ensure that the correct python is used.
        reinplace "s|${prefix}/bin/python|${prefix}/bin/python2.6|g" ${worksrcpath}/doc/tools/mkhowto
        reinplace "s| python | ${prefix}/bin/python2.6 |g" ${worksrcpath}/doc/Makefile
    }
    
    post-build {
        system "cd ${worksrcpath}/doc && /usr/bin/make html"
    }
    
    post-destroot {
        file copy ${worksrcpath}/doc/html ${destroot}${prefix}/share/doc/${name}
    }
}

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