# -*- 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
# $Id: Portfile 114324 2013-12-05 08:44:51Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           python 1.0

name                py-django
version             1.5.1
license             BSD
categories-append   www
platforms           darwin
maintainers         deric
homepage            http://www.djangoproject.com
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.

set branch          [join [lrange [split ${version} .] 0 1] .]
master_sites        https://www.djangoproject.com/m/releases/${branch}/
distname            Django-${version}
checksums           sha1    0ab97b90c4c79636e56337f426f1e875faccbba1 \
                    rmd160  fbeba9c331c66649a35bd86c84d04a9ca149c54e \
                    sha256  885fadcbb8963c0ccda5d9d2cca792970b0289b4e662406b2de2b736ff46123d

python.versions     26 27 32 33
python.default_version 27

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

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

    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
        if {${python.version} >= 26} {
            ln -s ${python.prefix}/bin/django-admin.py \
                ${destroot}${prefix}/bin/django-admin-${python.branch}.py
        } else {
            move ${destroot}${prefix}/bin/django-admin.py \
                ${destroot}${prefix}/bin/django-admin-${python.branch}.py
        }
    }
}

livecheck.type      regex
livecheck.url       http://www.djangoproject.com/download/
livecheck.regex     "The latest official version is (1\.\[0-9\]+\.\[0-9\]*)"
