# -*- 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-mysqlclient
version             2.2.7
revision            0

categories-append   devel databases
platforms           {darwin any}
license             GPL-2
maintainers         nomaintainer

description         Python3 interface to MySQL/MariaDB, fork of MySQL-python
long_description    {*}${description}

checksums           rmd160  cc7d8c9892f8ab85b1611a960aea9ef1cde79a90 \
                    sha256  24ae22b59416d5fcce7e99c9d37548350b4565baac82f95e149cac6ce4163845 \
                    size    91383

python.versions     310 311 312

if {${name} ne ${subport}} {
    set mysql_config {}

    depends_build-append \
                    port:pkgconfig \
                    port:py${python.version}-setuptools

    pre-configure {
        if {![variant_isset mysql57] &&
            ![variant_isset mysql8] &&
            ![variant_isset mariadb10_6] &&
            ![variant_isset mariadb10_11]} {
            return -code error "you must select either mysql57, mysql8, mariadb10_6, or mariadb10_11"
        }
    }

    variant mysql57 conflicts mysql8 mariadb10_6 mariadb10_11 \
        description {Access mysql57} {
        depends_lib-append  port:mysql57
        build.env-append PKG_CONFIG_PATH=${prefix}/lib/mysql57/mysql/pkgconfig
    }

    variant mysql8 conflicts mysql57 mariadb10_6 mariadb10_11 \
        description {Access mysql8} {
        depends_lib-append  port:mysql8
        build.env-append PKG_CONFIG_PATH=${prefix}/lib/mysql8/mysql/pkgconfig
    }

    variant mariadb10_6 conflicts mysql57 mysql8 mariadb10_11 \
        description {Access mariadb-10.6} {
        depends_lib-append  port:mariadb-10.6
        build.env-append PKG_CONFIG_PATH=${prefix}/lib/mariadb-10.6/mysql/pkgconfig
    }

    variant mariadb10_11 conflicts mysql57 mysql8 mariadb10_6 \
        description {Access mariadb-10.11} {
        depends_lib-append  port:mariadb-10.11
        build.env-append PKG_CONFIG_PATH=${prefix}/lib/mariadb-10.11/mysql/pkgconfig
    }

    if {![variant_isset mysql57] &&
            ![variant_isset mysql8] &&
            ![variant_isset mariadb10_6] &&
            ![variant_isset mariadb10_11] } {
        default_variants +mariadb10_11
    }
}
