# $Id: Portfile 86883 2011-11-06 17:59:22Z ram@macports.org $

PortSystem         1.0
PortGroup          python 1.0

name               py-m2crypto
version            0.21.1
categories-append  crypto devel
maintainers        ram openmaintainer
description        M2Crypto is a crypto and SSL toolkit for Python.
long_description   ${description}

platforms          darwin

homepage           http://chandlerproject.org/Projects/MeTooCrypto
master_sites       http://pypi.python.org/packages/source/M/M2Crypto/
distname           M2Crypto-${version}

python.versions    24 25 26 27

checksums          md5 f93d8462ff7646397a9f77a2fe602d17 \
                   sha1 3c7135b952092e4f2eee7a94c5153319cccba94e \
                   rmd160 313dcab450846a0363e7192a10364bdfd5dfae85

if {$subport != $name} {
  depends_lib-append port:swig-python \
                     port:openssl \
                     port:py${python.version}-distribute

  post-patch {
    reinplace "s|#extra_link_args|extra_link_args|g" ${worksrcpath}/setup.py
    reinplace "s|self.openssl = '/usr'|self.openssl = '${prefix}'|g" \
      ${worksrcpath}/setup.py
  }

  post-destroot {
    if {${name} != ${subport}} {
      xinstall -m 755 -d ${destroot}${prefix}/share/doc/${subport}
      eval file copy [glob ${worksrcpath}/doc/*] \
        ${destroot}${prefix}/share/doc/${subport}
    }
  }
}
if {${name} == ${subport}} {
  livecheck.type     regex
  livecheck.url      ${homepage}
  livecheck.regex    M2Crypto-(\[0-9\\.\]+)\.tar\.gz
} else {
  livecheck.type     none
}
