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

name                py-scikit-learn
version             1.7.2
revision            0
distname            scikit_learn-${version}

categories-append   science
license             BSD

python.versions     39 310 311 312 313

maintainers         {stromnov @stromnov} openmaintainer

description         Easy-to-use and general-purpose machine learning in Python

long_description    Scikit-learn integrates machine learning algorithms \
                    in the tightly-knit scientific Python world, building upon \
                    numpy, scipy, and matplotlib. As a machine-learning module, \
                    it provides versatile tools for data mining and analysis \
                    in any field of science and engineering.

homepage            https://scikit-learn.org/

checksums           rmd160  62aae858f955093394ccf21154d14b342c57e140 \
                    sha256  20e9e49ecd130598f1ca38a1d85090e1a600147b9c02fa6f15d69cb53d968fda \
                    size    7193136

if {${name} ne ${subport}} {
    if {${python.version} == 39} {
        version     1.6.1
        revision    0
        checksums   rmd160  32679385c5b7e3cda2fe9907bf8dab750192b5b4 \
                    sha256  b4fc2525eca2c69a59260f583c56a7557c6ccdf8deafdba6e060f94c1c59738e \
                    size    7068312
    }

    distname        scikit_learn-${version}

    # ensure MacPorts's Python is used, don't attempt the systems "python3"
    post-patch {
        reinplace "s|/usr/bin/env python3|${python.bin}|g" {*}[glob ${worksrcpath}/sklearn/_build_utils/*.py]
    }

    depends_build-append \
                        path:bin/cython-${python.branch}:py${python.version}-cython

    depends_lib-append  port:py${python.version}-numpy \
                        port:py${python.version}-scipy \
                        port:py${python.version}-joblib \
                        port:py${python.version}-threadpoolctl

    compiler.openmp_version 2.5

    if {[string match *clang* ${configure.compiler}]} {
        depends_lib-append  port:libomp
    }

    python.pep517_backend meson
    python.add_archflags no

    build.env-append    "CPPFLAGS=${configure.cppflags} -I${prefix}/include/libomp -Xpreprocessor -fopenmp" \
                        "CFLAGS=${configure.cc_archflags} -I${prefix}/include/libomp" \
                        "CXXFLAGS=${configure.cxx_archflags} -I${prefix}/include/libomp" \
                        "LDFLAGS=${configure.ld_archflags} -L${prefix}/lib/libomp -lomp" \
                        DYLD_LIBRARY_PATH=${prefix}/lib/libomp CYTHON=${prefix}/bin/cython-${python.branch}
    destroot.env-append "CPPFLAGS=${configure.cppflags} -I${prefix}/include/libomp -Xpreprocessor -fopenmp" \
                        "CFLAGS=${configure.cc_archflags} -I${prefix}/include/libomp" \
                        "CXXFLAGS=${configure.cxx_archflags} -I${prefix}/include/libomp" \
                        "LDFLAGS=${configure.ld_archflags} -L${prefix}/lib/libomp -lomp" \
                        DYLD_LIBRARY_PATH=${prefix}/lib/libomp CYTHON=${prefix}/bin/cython-${python.branch}

    livecheck.type      none
}
