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

name                py-pydicom
version             2.1.2
python.versions     27 36 37 38 39
platforms           darwin
license             MIT BSD
maintainers         {eborisch @eborisch} \
                    openmaintainer
supported_archs     noarch

description         Python Module for working with DICOM files

long_description    pydicom is a pure python package for working with DICOM \
                    files. It was made for inspecting and modifying DICOM \
                    files in an easy pythonic way. The modifications can be \
                    written again to a new file. As a pure python package, it \
                    should run anywhere python runs without any other \
                    requirements.

homepage            https://pydicom.github.io/pydicom/stable/index.html

if {${name} ne ${subport}} {
    if { ${subport} eq "py27-pydicom" } {
        github.setup        pydicom pydicom 1.4.2 v
        checksums \
            rmd160  df34e5bbd665f135df0f34e292bc8d7bfbc81659 \
            sha256  e47ced50f15ab7217dfe8a2463a23eb46079995c98e05178e0b2cba315aadb5e \
            size    35308760
    } else {
        github.setup        pydicom pydicom ${version} v
        checksums \
            rmd160  3a28811043ab2c96a0b1ef655ddbf27a9f9e97ae \
            sha256  d4565f499512258845fb36a36fd2e460e5cb1d044188471b6c217b12821b3aab \
            size    2090799
    }

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

    variant doc description "Build offline documentation" {
        depends_build-append \
            port:py${python.version}-alabaster \
            port:py${python.version}-matplotlib\
            port:py${python.version}-numpydoc \
            port:py${python.version}-Pillow \
            port:py${python.version}-sphinx \
            port:py${python.version}-sphinx-bootstrap-theme \
            port:py${python.version}-sphinx-copybutton \
            port:py${python.version}-sphinx-gallery \
            port:py${python.version}-sphinx-issues \
            port:py${python.version}-sphinx_rtd_theme

        notes "
            Documentation installed in :
              file://${prefix}/share/doc/${subport}/html/index.html
        "
    }

    post-extract {
        reinplace s/sphinx-build/sphinx-build-${python.branch}/ \
            doc/Makefile
        if {${subport} eq "py27-pydicom"} {
            reinplace {s/print(\(.*\), end=.*/print \1,/} \
                examples/input_output/plot_read_dicom_directory.py
        }
    }

    post-build {
        if {[variant_isset doc]} {
            system -W ${worksrcpath}/doc/ \
                "env PYTHONPATH='${worksrcpath}/build/lib' make html"
        }
    }

    post-destroot {
        set DOCDIR ${destroot}${prefix}/share/doc/${subport}
        xinstall -d ${DOCDIR}
        file copy ${worksrcpath}/LICENSE ${DOCDIR}

        if {[variant_isset doc]} {
            file copy ${worksrcpath}/doc/release_notes ${DOCDIR}
            file copy ${worksrcpath}/doc/_build/html ${DOCDIR}
        }
    }

    if {${subport} eq "py27-pydicom"} {
        # Backwards compatibility for upgraders
        notes \
"pydicom >= 1.0 changed the library name. Install py27-dicom for backward\
compatibility if required. (Can be installed without conflict.) See\
https://pydicom.github.io/pydicom/stable/transition_to_pydicom1.html\
for more information."
    }

    livecheck.type        none
}
