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

python.versions     310 311 312 313 314

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.

homepage            https://igraph.org/python/

checksums           rmd160  511e151aab881f5313efc59ef4148c66e094e876 \
                    sha256  2414d0be2e4d77ee5357807d100974b40f6082bb1bb71988ec46cfb6728651ee \
                    size    5077105

variant external_igraph description {Use external igraph library} { }

default_variants +external_igraph

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

    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
}
