# -*- 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-virtualenv
version             21.5.1
revision            0

categories-append   devel
platforms           {darwin any}
supported_archs     noarch
license             MIT
maintainers         {reneeotten @reneeotten} {larryv @larryv} openmaintainer

description         Virtual Python Environment builder
long_description    virtualenv is a tool to create isolated Python \
                    environments.

homepage            https://virtualenv.pypa.io

checksums           rmd160  1ca2f447315ed83b9af91f436fd182c2c7fa1df0 \
                    sha256  dca3bf98275a59c652b69d68e73433e597d977c2da9198882479d1a7188009c8 \
                    size    4578798

# keep Python version 2.7 here, other EOL Python versions can be removed
# See <https://trac.macports.org/wiki/Python#VersionPolicy>
python.versions     27 310 311 312 313 314

if {${name} ne ${subport}} {
    depends_lib     port:py${python.version}-distlib \
                    port:py${python.version}-filelock \
                    port:py${python.version}-platformdirs \
                    port:py${python.version}-python-discovery

    if {${python.version} < 311} {
        depends_lib-append \
                    port:py${python.version}-typing_extensions
    }

    if {${python.version} == 27} {
        PortGroup   deprecated 1.0
        deprecated.eol_version  yes

        depends_build-append \
                        port:py${python.version}-setuptools_scm

        depends_lib-delete \
                    port:py${python.version}-typing_extensions \
                    port:py${python.version}-python-discovery

        depends_lib-append \
                        port:py${python.version}-importlib-resources \
                        port:py${python.version}-importlib-metadata \
                        port:py${python.version}-contextlib2 \
                        port:py${python.version}-pathlib2 \
                        port:py${python.version}-six

        version     20.15.1
        revision    0
        checksums   rmd160  22ae6412f07079cc66ab083e63b234da203e99da \
                    sha256  288171134a2ff3bfb1a2f54f119e77cd1b81c29fc1265a2356f3e8d14c7d58c4 \
                    size    13523736

        post-destroot {
            set docdir ${prefix}/share/doc/${subport}
            xinstall -d ${destroot}${docdir}/docs/changelog
            xinstall -m 0644 -W ${worksrcpath} README.md LICENSE \
                ${destroot}${docdir}
            xinstall -m 0644 {*}[glob -directory ${worksrcpath}/docs *.rst] \
                    ${destroot}${docdir}/docs
            xinstall -m 0644 {*}[glob -directory ${worksrcpath}/docs/changelog *] \
                    ${destroot}${docdir}/docs/changelog
        }

    } else {
        # latest upstream version
        python.pep517       yes
        python.pep517_backend   hatch

        depends_build-append \
                        port:py${python.version}-hatch-vcs
    }

    depends_run-append  port:virtualenv_select

    select.group        virtualenv
    select.file         virtualenv${python.version}

    notes-append "
    The executable is installed as\
    '${prefix}/bin/virtualenv-${python.branch}'. To symlink it to\
    '${prefix}/bin/virtualenv', run:

        sudo port select --set ${select.group} ${select.file}
    "

    livecheck.type  none
}
