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

name                py-pygments
python.rootname     Pygments
version             2.19.2
revision            0
categories-append   devel
license             BSD
supported_archs     noarch
platforms           {darwin any}

python.versions     27 35 36 37 38 39 310 311 312 313 314
python.pep517_backend \
                    hatch

maintainers         {stromnov @stromnov} openmaintainer

description         Python syntax highlighter

long_description \
    Pygments is a fast syntax highlighter written in Python with a \
    special focus on details. Can highlight source code in many supported \
    languages: Python, Ruby, PHP, HTML etc. Outputs arbitrarily-styled \
    HTML or LaTeX, comes with many builtin styles.

homepage            https://pygments.org/

checksums           rmd160  26de404ae973929ccf48ef77df13bd010bf9611d \
                    sha256  636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887 \
                    size    4968631

distname            pygments-${version}

if {${name} ne ${subport}} {

    if {${python.version} eq 27} {
        version             2.5.2
        revision            0
        checksums           rmd160  e38d8d2e69af42784f2b7235ba5ee464df71901b \
                            sha256  98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe \
                            size    20263984
    } elseif {${python.version} eq 35} {
        version             2.11.2
        revision            0
        checksums           md5 217b4355612df4b61dc570df4b0148ba \
                            rmd160 17441b0692d892a6c95429ec3dc004cd0c7ccef3 \
                            sha256 4e426f72023d88d03b2fa258de560726ce890ff3b630f88c21cbb8b2503b8c6a
    } elseif {${python.version} eq 36} {
        version             2.14.0
        revision            0
        checksums           md5 447be4afb076c8325a7dc659aff5b931 \
                            rmd160 ef3c29232ca28084efc5be0a1e93ed1ae56cd7c6 \
                            sha256 b3ed06a9e8ac9a9aae5a6f5dbe78a8a58655d17b43b93c078f094ddc476ae297
    } elseif {${python.version} eq 37} {
        version             2.17.2
        revision            0
        checksums           rmd160  24e98871a0006d0191e0b75e2d9bab76894a5726 \
                            sha256  da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367 \
                            size    4827772
        distname            pygments-${version}
    }

    if {${python.version} in {37 36}} {
        depends_run-append  port:py${python.version}-importlib-metadata
    }
    if {${python.version} < 37} {
        distname            ${python.rootname}-${version}
        depends_lib-append  port:py${python.version}-setuptools
    }

    depends_run-append  port:pygments_select

    post-destroot {
        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 644 -W ${worksrcpath} AUTHORS CHANGES LICENSE \
            ${destroot}${docdir}
        set man1 ${python.prefix}/share/man/man1
        xinstall -d ${destroot}${man1}
        xinstall -m 644 ${worksrcpath}/doc/pygmentize.1 ${destroot}${man1}
        ln -sf ${man1}/pygmentize.1 \
            ${destroot}${prefix}/share/man/man1/pygmentize-${python.branch}.1
    }

    select.group        pygments
    select.file         ${filespath}/py${python.version}-pygments

    notes "
To make the Python ${python.branch} version of Pygments the one that is run when\
you execute the commands without a version suffix, e.g. 'pygmentize', run:

port select --set ${select.group} [file tail ${select.file}]
"

    livecheck.type      none
}
