# -*- 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

PortSystem          1.0
PortGroup           python 1.0
PortGroup           github 1.0

name                pypi2port
livecheck.version   2023-06-21
version             [string map {- ""} ${livecheck.version}]
github.setup        macports macports-contrib ${version} ${name}-
revision            2

categories          sysutils macports
platforms           any
maintainers         nomaintainer
license             BSD
supported_archs     noarch

description         generate Portfiles from PyPI
long_description    A python script to {*}${description}.
homepage            https://trac.macports.org/wiki/${name}

github.tarball_from releases
use_bzip2           yes
distname            ${name}-${version}
checksums           rmd160 957e125f66d83933ba9a8c9680f9a208d9aef3f4 \
                    sha256 bcf120fbd236809a6530fa17fc223dba39b78a63a0738204d6a9b7b26dd1425c

python.default_version 314
python.pep517       no

depends_run-append  port:py${python.version}-requests

worksrcdir          ${name}

build {}

post-patch {
    reinplace "s|#!/usr/bin/env python|#!${python.bin}|" ${worksrcpath}/${name}.py
}

destroot {
    xinstall ${worksrcpath}/${name}.py ${destroot}${prefix}/bin/${name}

    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 ${worksrcpath}/README.txt ${destroot}${docdir}
}

livecheck.type      regexm
livecheck.url       https://github.com/macports/macports-contrib/commits/master.atom
livecheck.regex     {<title>[^<]*pypi2port[^<]*</title>\s*<updated>([0-9-]+)T}
