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

name                py-colour
github.setup        colour-science colour 0.4.6 v
github.tarball_from archive
revision            0

license             BSD
maintainers         {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description         A comprehensive number of colour theory transformations and algorithms
long_description \
    Colour is a Python colour science package implementing a comprehensive number of colour theory transformations and algorithms.

supported_archs     noarch
platforms           {darwin any}

homepage            https://www.colour-science.org

checksums           rmd160  bc439fc36b7a1d912db21e47938300fe3032ca0c \
                    sha256  7029f4b8240a8a8308d9956f383ed8077527ccbb651466d6b5fbb663691a5eeb \
                    size    2268193

python.versions     312
python.pep517_backend hatch

if {${name} ne ${subport}} {
    # see https://www.colour-science.org/installation-guide/
    depends_lib-append \
        port:py${python.version}-numpy \
        port:py${python.version}-imageio \
        port:py${python.version}-scipy \
        port:py${python.version}-typing_extensions

    # optional dependencies
    depends_run-append \
        port:py${python.version}-networkx \
        port:py${python.version}-pandas \
        port:py${python.version}-matplotlib \
        path:bin/dot:graphviz \
        port:py${python.version}-graphviz

    variant openimageio description {Enable support for OpenImageIO} {
        depends_run-append \
            port:openimageio
        require_active_variants openimageio python${python.version}
    }

    test.run        yes
    python.test_framework nose

    depends_test-append \
        port:py${python.version}-mock

    test.target     nosetests

    variant docs description {Install Sphinx-generated docs} {
        depends_build-append       port:py${python.version}-sphinx \
                                   port:py${python.version}-sphinx_rtd_theme \
                                   port:py${python.version}-sphinxcontrib-bibtex

        post-build {
            system -W ${worksrcpath}/docs "make PYTHONPATH=${worksrcpath}/build/lib SPHINXBUILD=${prefix}/bin/sphinx-build-${python.branch} html man"
        }

        post-destroot {
            set doc_build_dir ${worksrcpath}/docs/_build
            file delete -force ${doc_build_dir}/html/.buildinfo \
                ${doc_build_dir}/html/_sources
            copy ${doc_build_dir}/html \
                ${destroot}${prefix}/share/doc/${subport}
            move ${doc_build_dir}/man \
                ${destroot}${python.prefix}
        }
    }
}
