# -*- 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-bsddb3
version                 6.2.9
revision                2

categories-append       databases
license                 MIT
maintainers             {mascguy @mascguy} openmaintainer

description             Python 3 bindings for Oracle Berkeley DB
long_description        This port provides a nearly complete wrapping \
                        of the Oracle/Sleepycat C API for the Database \
                        Environment, Database, Cursor, Log Cursor, \
                        Sequence and Transaction objects. Each of \
                        these is exposed as a Python type in the \
                        bsddb3.db module.

homepage                https://pypi.python.org/pypi/${python.rootname}

checksums               rmd160  dd01d1fa55d37cd4948b539f8f6296a89cb9f433 \
                        sha256  70d05ec8dc568f42e70fc919a442e0daadc2a905a1cfb7ca77f549d49d6e7801 \
                        size    230475

python.versions         310 311 312 313
python.link_binaries    no
python.move_binaries    no

# replication requires Berkeley DB >= 5.1
# use with Oracle Berkeley DB >= 6.0 has licensing issues
# http://www.jcea.es/programacion/pybsddb.htm

proc bdb_setup {db_version} {
    global prefix

    depends_lib-append \
                        port:db${db_version}

    foreach phase {build destroot} {
        ${phase}.env-append \
                        BERKELEYDB_INCDIR=${prefix}/include/db${db_version} \
                        BERKELEYDB_LIBDIR=${prefix}/lib/db${db_version} \
                        YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=1
    }
}

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

    variant db53 conflicts db60 db62 \
            description {support for BerkeleyDB 5.3.x} {
        bdb_setup 53
    }

    variant db60 conflicts db53 db62 \
            description {support for BerkeleyDB 6.0.x} {
        bdb_setup 60
    }

    variant db62 conflicts db53 db60 \
            description {support for BerkeleyDB 6.2.x} {
        bdb_setup 62
    }

    if {![variant_isset db53] && \
        ![variant_isset db60] && \
        ![variant_isset db62] } {
        default_variants +db62
    }

    livecheck.type      none
}
