# -*- 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-igraph
version             0.11.9
revision            1
categories-append   math science
license             GPL-2+

python.versions     39 310 311 312 313

maintainers         {snc @nerdling} {gmail.com:szhorvat @szhorvat} openmaintainer

description         Python interface to the igraph library.

long_description    Python interface to the igraph library for network analysis \
                    and graph theory. Also install py-cairocffi to enable \
                    visualization functionality.

homepage            https://igraph.org/python/

checksums           rmd160  678bbeea28cd4d2062f1183efba4a0d2c1a638c3 \
                    sha256  c57ce44873abcfcfd1d61d7d261e416d352186958e7b5d299cf244efa6757816 \
                    size    4587322

variant external_igraph description {Use external igraph library} { }

if {${name} ne ${subport}} {
    compiler.c_standard     1999
    compiler.cxx_standard   2011

    depends_lib-append      port:py${python.version}-texttable

    # Removes the CMake dependency from pyproject.toml
    # We use MacPorts's CMake instead
    patchfiles              remove-cmake-dependency.patch

    if {[variant_isset external_igraph]} {
        # Build with external igraph library

        depends_lib-append      port:igraph

        depends_build-append    path:bin/pkg-config:pkgconfig

        build.args-append       -C--global-option=--use-pkg-config
    } else {
        # Build with vendored igraph library

        depends_lib-append      port:arpack \
                                port:glpk \
                                port:gmp \
                                port:libxml2 \
                                port:plfit

        depends_build-append    path:bin/cmake:cmake

        set extra_cmake_args {
            -DUSE_CCACHE=OFF
            -DBUILD_SHARED_LIBS=OFF
            -DIGRAPH_ENABLE_LTO=AUTO
            -DIGRAPH_GLPK_SUPPORT=ON
            -DIGRAPH_GRAPHML_SUPPORT=ON
            -DIGRAPH_USE_INTERNAL_ARPACK=OFF
            -DIGRAPH_USE_INTERNAL_BLAS=OFF
            -DIGRAPH_USE_INTERNAL_GLPK=OFF
            -DIGRAPH_USE_INTERNAL_GMP=OFF
            -DIGRAPH_USE_INTERNAL_LAPACK=OFF
            -DIGRAPH_USE_INTERNAL_PLFIT=OFF
            -DIGRAPH_OPENMP_SUPPORT=OFF
            -DBLA_VENDOR=Apple
        }

        build.env-append        IGRAPH_CMAKE_EXTRA_ARGS=[join $extra_cmake_args]
    }

    # python-igraph optionally makes use of these, and some tests depend on them.
    # If they are not installed, the corresponding tests will simply be skipped.
    depends_test-append     port:py${python.version}-matplotlib \
                            port:py${python.version}-networkx \
                            port:py${python.version}-numpy \
                            port:py${python.version}-pandas \
                            port:py${python.version}-scipy

    test.run yes
}
