# -*- 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           github 1.0
PortGroup           python 1.0

github.setup        django django 2.0.3
name                py-django2
categories-append   www
platforms           darwin
license             BSD
# feel free to take over this port
maintainers         {@mojca mojca} openmaintainer

description         Django is a high-level Python Web framework
long_description    Django is a high-level Python Web framework that \
                    encourages rapid development and clean, pragmatic \
                    design.

homepage            http://www.djangoproject.com

checksums           rmd160  cdd4fac4aa634be509ef8ee5d1569fc7a7d21c0c \
                    sha256  d0fe12b6bc6a4ba353d19e192d649e184ab7c6f1b38043e8440875f5eec8d811

python.versions     35 36
supported_archs     noarch

if {${name} ne ${subport}} {
    conflicts               py${python.version}-django

    depends_build-append    port:py${python.version}-setuptools
    depends_run             port:py${python.version}-tz

    variant bash_completion {
        depends_run-append  path:etc/bash_completion:bash-completion

        post-patch {
            reinplace "s|django-admin.py|django-admin-${python.branch}.py|g" \
                ${worksrcpath}/extras/django_bash_completion
        }

        post-destroot {
            xinstall -d ${destroot}${prefix}/etc/bash_completion.d
            xinstall -m 644 ${worksrcpath}/extras/django_bash_completion \
                ${destroot}${prefix}/etc/bash_completion.d/django-admin-${python.branch}.py
        }
    }

    # we want *-${python.branch}.py not *.py-${python.branch}
    python.link_binaries no
    python.move_binaries no
    post-destroot   {
        xinstall -m 644 -W ${worksrcpath} \
            AUTHORS INSTALL LICENSE README.rst \
            ${destroot}${prefix}/share/doc/${subport}

        file copy ${worksrcpath}/docs \
            ${destroot}${prefix}/share/doc/${subport}/docs

        # To avoid conflict between py*-django
        ln -s ${python.prefix}/bin/django-admin.py \
            ${destroot}${prefix}/bin/django-admin-${python.branch}.py
    }

    livecheck.type  none
}