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

name			py-gdbm
version			2.4.6
revision        2
categories-append	databases
license			PSF
maintainers		nomaintainer
description		Python bindings to the GNU dbm library
long_description	{*}${description}

homepage		https://docs.python.org/2/library/gdbm.html

python.versions 26 27 32 33 34 35 36 37 38 39 310 311 312

subport py26-gdbm {
    maintainers     {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
    version         2.6.9
    revision        2
    checksums       md5 933a811f11e3db3d73ae492f6c3a7a76 \
                    rmd160 42edf7c9f2f64b77ab173de30ea453257c2c06b3 \
                    sha256 cae7bb995006ea5b703d9d28446f694894c441fe4bfb95d561c0ac908cd06e41
    set setup_files [list setup.py]
    set extract_files [list Modules/gdbmmodule.c]
    livecheck.regex {Python (2\.6\.[0-9]+)}
}
subport py27-gdbm {
    maintainers     {jmr @jmroot} openmaintainer
    version         2.7.18
    revision        0
    checksums       md5 fd6cc8ec0a78c44036f825e739f36e5a \
                    rmd160 40a514bb05c9e631454ea8466e28f5bb229428ad \
                    sha256 b62c0e7937551d0cc02b8fd5cb0f544f9405bafc9a54d3808ed4594812edef43
    set setup_files [list setup.py]
    set extract_files [list Modules/gdbmmodule.c]
    livecheck.regex {Python (2\.7\.[0-9]+)}
}
subport py32-gdbm {
    maintainers     {jmr @jmroot}
    version         3.2.6
    revision        2
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5     e0ba4360dfcb4aec735e666cc0ae7b0e \
                    rmd160  f3f5877cd3ac03151f161353e808a38204f1270d \
                    sha256  1d12b501819fd26afafbf8459be1aa279b56f032b4c15412de0a713ce0de7bdc
    livecheck.regex {Python (3\.2\.[0-9]+)}
}
subport py33-gdbm {
    maintainers     {jmr @jmroot}
    version         3.3.7
    epoch           20141012
    revision        2
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 84e2f12f044ca53b577f6224c53f82ac \
                    rmd160 3a915ea86ef3826fc0483eb94a2b4e2b9ad787b1 \
                    sha256 85f60c327501c36bc18c33370c14d472801e6af2f901dafbba056f61685429fe
    livecheck.regex {Python (3\.3\.[0-9]+)}
}
subport py34-gdbm {
    maintainers     {jmr @jmroot} openmaintainer
    epoch           20170810
    version         3.4.10
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 f88a98bce17a03c43a6a5f8a66ab2e62 \
                    rmd160 050bb8f215d9b5ed8287b2a9f9faa6448d7513a5 \
                    sha256 d46a8f6fe91679e199c671b1b0a30aaf172d2acb5bcab25beb35f16c3d195b4e
    livecheck.regex {Python (3\.4\.[0-9]+)}
}
subport py35-gdbm {
    maintainers     {jmr @jmroot} openmaintainer
    epoch           20170810
    version         3.5.10
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 75c9c268703654aa6f6f2ae67303dde4 \
                    rmd160 5ec7da2d568f963a81b78433bf72ed1ad9e87292 \
                    sha256 0f0fa8685c1dc1f1dacb0b4e7779796b90aef99dc1fa4967a71b9da7b57d4a28
    livecheck.regex {Python (3\.5\.[0-9]+)}
}
subport py36-gdbm {
    maintainers     {jmr @jmroot}
    epoch           20170717
    version         3.6.15
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 bc04aa6c2a1a172a35012abd668538cd \
                    rmd160 eb84f49be5de3e2cc93059b9e90d3d42c971a90f \
                    sha256 6e28d7cdd6dd513dd190e49bca3972e20fcf455090ccf2ef3f1a227614135d91
    livecheck.regex {Python (3\.6\.[0-9]+)}
}
subport py37-gdbm {
    maintainers     {jmr @jmroot}
    version         3.7.17
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 dd94cab4541b57b88cf3dab32d6336e3 \
                    rmd160 4dc4fb8286e8550da79a610ecb3a161757cf0886 \
                    sha256 7911051ed0422fd54b8f59ffc030f7cf2ae30e0f61bda191800bb040dce4f9d2
    livecheck.regex {Python (3\.7\.[0-9]+)}
}
subport py38-gdbm {
    maintainers     nomaintainer
    version         3.8.20
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 745478c81d6382cf46b5e7ad89e56008 \
                    rmd160 1d03db4e018f2133f2b279a3a44f0c7c759c50cf \
                    sha256 6fb89a7124201c61125c0ab4cf7f6894df339a40c02833bfd28ab4d7691fafb4
    livecheck.regex {Python (3\.8\.[0-9]+)}
}
subport py39-gdbm {
    maintainers     {jmr @jmroot}
    version         3.9.22
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 cee32bb2e6abf73bd8dda59a6f5f56bd \
                    rmd160 a1219b3b428a72948d5f5b60b39e3b3e1f722fba \
                    sha256 8c136d199d3637a1fce98a16adc809c1d83c922d02d41f3614b34f8b6e7d38ec
    livecheck.regex {Python (3\.9\.[0-9]+)}
}
subport py310-gdbm {
    maintainers     {jmr @jmroot}
    version         3.10.18
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 14ea0982a7dd4dbfc3f50537c723df41 \
                    rmd160 86163aa427f3d8572f247e77fafdf3599ff07f38 \
                    sha256 ae665bc678abd9ab6a6e1573d2481625a53719bc517e9a634ed2b9fefae3817f
    livecheck.regex {Python (3\.10\.[0-9]+)}
}
subport py311-gdbm {
    maintainers     {jmr @jmroot}
    version         3.11.13
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 ec39a8018b9eedf6f0edeb44533bd279 \
                    rmd160 997ef93bc4718e6541055e9e30f7684f8a534143 \
                    sha256 8fb5f9fbc7609fa822cb31549884575db7fd9657cbffb89510b5d7975963a83a
    livecheck.regex {Python (3\.11\.[0-9]+)}
}
subport py312-gdbm {
    maintainers     {jmr @jmroot}
    version         3.12.11
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 9613d56b90d0d0cfd19980c7e2956a06 \
                    rmd160 5006b40a6aca643b329ae6b9b6dc141746d13a94 \
                    sha256 c30bb24b7f1e9a19b11b55a546434f74e739bb4c271a3e3a80ff4380d49f7adb
    livecheck.regex {Python (3\.12\.[0-9]+)}
}
subport py313-gdbm {
    maintainers     {jmr @jmroot}
    version         3.13.4
    revision        0
    homepage        https://docs.python.org/release/${version}/library/dbm.html
    checksums       md5 2e2a8eb2e1be50049dc4248d99a52f89 \
                    rmd160 f7e6b82f037e15447f4ec35d360d00e3bcb0afb2 \
                    sha256 27b15a797562a2971dce3ffe31bb216042ce0b995b39d768cf15f784cc757365
    livecheck.regex {Python (3\.13\.[0-9]+)}
}


distname		Python-${version}
master_sites	https://www.python.org/ftp/python/${version}/

livecheck.type	none

if {${name} ne ${subport}} {
    use_xz      yes

    depends_lib-append	port:gdbm

    dist_subdir		python${python.version}

    worksrcdir	${worksrcdir}/Modules

    if {${python.version} >= 37} {
        python.pep517   yes
        set setup_files [list pyproject.toml setup-pep517.py]
        post-destroot {
            xinstall -d ${destroot}${python.libdir}/lib-dynload
            move {*}[glob ${destroot}${python.pkgd}/*.so] ${destroot}${python.libdir}/lib-dynload
            delete ${destroot}${python.pkgd}
        }
    } elseif {${python.version} >= 30} {
        set setup_files [list setup-py3k.py]
    }
    if {${python.version} >= 30} {
        set extract_files [list Modules/_gdbmmodule.c]
        if {${python.version} >= 35} {
            lappend extract_files Modules/clinic/_gdbmmodule.c.h
        }
    }

    foreach f $extract_files {
        lappend extract_files_full [shellescape ${distname}/${f}]
    }
    extract.post_args	"| tar -xf - [join ${extract_files_full}]"
    post-extract {
        foreach f $setup_files {
            if {[string match setup-*.py $f]} {
                copy    ${filespath}/${f} ${worksrcpath}/setup.py
            } else {
                copy    ${filespath}/${f} ${worksrcpath}
            }
        }
    }

    patch {
        reinplace "s|__PREFIX__|${prefix}|" ${worksrcpath}/setup.py
        if {[file exists ${worksrcpath}/pyproject.toml]} {
            reinplace "s|__VERSION__|${version}|" ${worksrcpath}/pyproject.toml
            reinplace "s|__PYTHON_INCDIR__|${python.include}|" ${worksrcpath}/setup.py
        } else {
            reinplace "s|__VERSION__|${version}|" ${worksrcpath}/setup.py
        }
    }

    livecheck.type	regex
    livecheck.url	https://www.python.org/downloads/
}
