# -*- 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 120198 2014-05-19 10:43:47Z stromnov@macports.org $

PortSystem          1.0
PortGroup           python 1.0
PortGroup           select 1.0

set realname        pip

name                py-${realname}
version             1.5.6
categories-append   www
license             MIT
platforms           darwin
supported_archs     noarch

python.versions     25 26 27 31 32 33 34

maintainers         stromnov openmaintainer

description         A tool for installing and managing Python packages.

long_description    pip is a replacement for easy_install. It uses mostly the \
                    same techniques for finding packages, so packages that \
                    were made easy_installable should be pip-installable as \
                    well.

homepage            http://www.pip-installer.org/
master_sites        http://pypi.python.org/packages/source/p/pip/

distname            ${realname}-${version}

checksums           rmd160  4353b4738860b3b0e3007e861e47986b8cc81ddc \
                    sha256  b1a4ae66baf21b7eb05a5e4f37c50c2706fa28ea1f8780ce8efe14dcd9f1726c

# Last version (1.3.1) with py25 support
subport py25-pip {
    version             1.3.1
    revision            1
    distname            ${realname}-${version}
    checksums           rmd160  0bfbfbc536abcf20f952b444ee872128406e098e \
                        sha256  145eaa5d1ea1b062663da1f3a97780d7edea4c63c68a37c463b1deedf7bb4957
    livecheck.type      none
}

if {${name} ne ${subport}} {
    depends_lib-append  port:py${python.version}-setuptools
    depends_run         port:pip_select

    if {${subport} eq "py25-${realname}"} {
        python.link_binaries_suffix
        python.move_binaries no
        post-destroot {
            copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${subport}
            delete ${destroot}${prefix}/bin/pip
        }
    } else {
        post-destroot {
            eval xinstall -m 644 [glob -types f ${worksrcpath}/docs/*] ${destroot}${prefix}/share/doc/${subport}

            xinstall -m 755 -d ${destroot}${prefix}/share/doc/${subport}/reference
            eval xinstall -m 644 [glob -types f ${worksrcpath}/docs/reference/*] ${destroot}${prefix}/share/doc/${subport}/reference

            delete ${destroot}${prefix}/bin/pip[string range ${python.version} 0 end-1]-${python.branch}
            delete ${destroot}${prefix}/bin/pip${python.branch}-${python.branch}
        }
    }

    select.group            ${realname}
    select.file             ${filespath}/${realname}${python.version}

    notes "
    To make the Python ${python.branch} version of pip the one that is run\
    when you execute the commands without a version suffix, e.g. 'pip', run:

    port select --set ${select.group} [file tail ${select.file}]
    "

    livecheck.type      none
} else {
    livecheck.type      regex
    livecheck.url       ${master_sites}
    livecheck.regex     {pip-(\d+(?:\.\d+)*)\.[tz]}
}
