# -*- 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           github 1.0
PortGroup           python 1.0

github.setup        scikit-learn-contrib hdbscan 0.8.33
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                py-${github.project}
revision            0
categories-append   science
license             BSD
supported_archs     arm64 x86_64

python.versions     39 310 311

maintainers         nomaintainer

description         A high performance implementation of HDBSCAN clustering.

long_description    HDBSCAN - Hierarchical Density-Based Spatial \
                    Clustering of Applications with Noise. Performs \
                    DBSCAN over varying epsilon values and integrates \
                    the result to find a clustering that gives the \
                    best stability over epsilon. This allows HDBSCAN \
                    to find clusters of varying densities (unlike \
                    DBSCAN), and be more robust to parameter \
                    selection. In practice this means that HDBSCAN \
                    returns a good clustering straight away with \
                    little or no parameter tuning -- and the primary \
                    parameter, minimum cluster size, is intuitive and \
                    easy to select. HDBSCAN is ideal for exploratory \
                    data analysis\; it's a fast and robust algorithm \
                    that you can trust to return meaningful clusters \
                    (if there are any).

homepage            https://hdbscan.readthedocs.io/en/latest/

checksums           rmd160  c189179d27ae15f43bd80d599aff7d9307dd4f17 \
                    sha256  01752253abf1871f9fe332a54bf770eaf9ee3a01e49c651147c5e297618ae207 \
                    size    11668514

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

    # Not compatible with Cython 3 as of 0.8.33
    set compat_path [string replace ${python.pkgd} 0 [string length ${python.prefix}]-1 ${prefix}/lib/py${python.version}-cython-compat]
    build.env-append    PYTHONPATH=${compat_path}

    depends_lib-append \
                    port:libomp \
                    port:py${python.version}-numpy \
                    port:py${python.version}-scikit-learn \
                    port:py${python.version}-scipy \
                    port:py${python.version}-six
    depends_run-append \
                    port:py${python.version}-joblib
    depends_test-append \
                    port:py${python.version}-nose

    compiler.openmp_version 2.5

    patchfiles-append \
                    patch-pyproject_toml.diff

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

    test.run        yes
}
