# -*- 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-ligo-segments
version             1.4.0
revision            1

categories-append   science
maintainers         nomaintainer
license             GPL-3

description         Representations of semi-open intervals
long_description    Defines the `segment`, `segmentlist`, and `segmentlistdict` \
                    objects for manipulating semi-open intervals.

homepage            https://git.ligo.org/lscsoft/ligo-segments

checksums           rmd160  33c0c9c6aa6ace5e4d86df7851de5072d08c8962 \
                    sha256  e072a844713c5b02efdcaf5bfe4c3a8cd9ef225b08cfd3202a4e185e0f71f5dc \
                    size    51015

python.versions     312 313 314

if {${name} ne ${subport}} {
    # fix permissions
    post-extract {
        fs-traverse item ${worksrcpath} {
            if {[file isdirectory ${item}]} {
                file attributes ${item} -permissions a+rx
            } elseif {[file isfile ${item}]} {
                file attributes ${item} -permissions a+r
            }
        }
    }

    # https://git.ligo.org/lscsoft/ligo-segments/-/merge_requests/38
    patchfiles-append   be7c93b1ef431908a9df0f078815ee7f00345088.patch \
                        fix-pylist-extend-python313.patch
    patch.pre_args-replace  -p0 -p1

    depends_lib-append  port:py${python.version}-six \
                        port:py${python.version}-ligo-common

    post-destroot {
        file delete -force ${destroot}/${python.pkgd}/ligo/__pycache__

        if {[file exists ${python.pkgd}/ligo/__init__.py]} {
            file delete -force ${destroot}/${python.pkgd}/ligo/__init__.py
        }
    }
}
