# -*- 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-importlib-metadata
python.rootname     importlib_metadata
version             9.0.0
revision            0
categories-append   devel
license             Apache-2
supported_archs     noarch
platforms           {darwin any}

# keep version for Python 2.7, which is an (indirect) dependencies of py-virtualenv
# See <https://trac.macports.org/wiki/Python#VersionPolicy>
python.versions     27 36 37 38 39 310 311 312 313 314

maintainers         {stromnov @stromnov} openmaintainer

description         Library to access the metadata for a Python package.
long_description    {*}${description}

homepage            https://importlib-metadata.readthedocs.io/

checksums           rmd160  00fc87dd63f3dedbb619e592b1dc71e547a76311 \
                    sha256  a4f57ab599e6a2e3016d7595cfd72eb4661a5106e787a95bcc90c7105b831efc \
                    size    56405

if {${name} ne ${subport}} {
    depends_build-append \
                        port:py${python.version}-setuptools

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

    if {${python.version} in "27 35"} {
        version             2.1.3
        epoch               1
        revision            0
        checksums           md5 10bf15d611e8d61d6f7b3aa112196fca \
                            rmd160 d06849e3ef8a1ddf6359bd266a30562ba92e29f6 \
                            sha256 02a9f62b02e9b1cc43871809ef99947e8f5d94771392d666ada2cafc4cd09d4f \
                            size   30408
        if {${python.version} eq 27} {
            depends_lib-append  port:py${python.version}-contextlib2 \
                                port:py${python.version}-configparser \
                                port:py${python.version}-pathlib2
        }
    } elseif {${python.version} eq "36"} {
        version             4.8.3
        epoch               1
        revision            0
        checksums           rmd160  f5952a964e77c80896fa03f66de0ace77b5a5935 \
                            sha256  766abffff765960fcc18003801f7044eb6755ffae4521c8e8ce8e83b9c9b0668 \
                            size    41979
    } elseif {${python.version} eq "37"} {
        version             6.7.0
        epoch               1
        revision            0
        checksums           rmd160  8c61967b759c5b5a97acba81fe6973f389b47f73 \
                            sha256  1aaf550d4f73e5d6783e7acb77aec43d49da8017410afae93822cc9cca98c4d4 \
                            size    53569
        python.pep517       no
        patchfiles-append   patch-setup.py.diff
    } elseif {${python.version} in "38 39"} {
        version             8.7.0
        revision            0
        checksums           rmd160  f99eb9e43f7461cb0d2239bbb33eff084f5030e5 \
                            sha256  d13b81ad223b890aa16c5471f2ac3056cf76c5f10f82d6f9292f0b415f389000 \
                            size    56641
        patchfiles-append   patch-pyproject.toml.diff
    } else {
        depends_lib-append \
                        port:py${python.version}-coherent.licensed
    }

    if {${python.version} in "36 37"} {
        depends_lib-append \
                        port:py${python.version}-typing_extensions
    }

    if {${python.version} in {37 38 39}} {
        revision            0
        # See issue: https://trac.macports.org/ticket/72425
        post-patch {
            reinplace "s|dynamic = \\\[\\\"version\\\"\\\]|version = \"${version}\"|" pyproject.toml
        }
        # break circular dependency with py-build
        python.add_dependencies no
        depends_build-append   port:py-bootstrap-modules \
                               port:py${python.version}-installer
        depends_lib-append     port:python${python.version}
        build.env-append    PYTHONPATH=${prefix}/share/py-bootstrap-modules
        if {${python.version} > 37} {
            build.args      --skip-dependency-check
        }
    } else {
        depends_build-append \
                        port:py${python.version}-setuptools_scm
    }

    livecheck.type      none
}
