# $Id: Portfile 69520 2010-07-08 20:19:52Z jmr@macports.org $

PortSystem 1.0

name			py-psycopg
version			1.1.21
revision		2
categories		python databases
maintainers		nomaintainer
platforms		darwin freebsd
description		a python DBAPI-2.0 ompliant database adapter for postgresql
long_description	psycopg is a postgresql database adapter for python. \
				It's fully compliant to pythons DBAPI-2.0. psycopg is \
				designed for heavily multi-threaded applications \
				featuring connection pooling.

homepage		http://www.initd.org/software/initd/psycopg/
master_sites	http://initd.org/pub/software/psycopg/
distname		psycopg-${version}
checksums		md5 a31f79f68d6d32898d6f24e11369a106

depends_lib		port:py-mx \
			port:python24 \
			port:openssl

configure.env	LDFLAGS="-L${prefix}/lib -lssl" \
				CPPFLAGS="-I${prefix}/lib/python2.4/site-packages/mx/DateTime/mxDateTime/"
configure.args	--with-python=${prefix}/bin/python2.4

variant postgresql82 conflicts postgresql83 description {Build against postgresql82} {
	depends_lib-append	port:postgresql82
	configure.args-append	--with-postgres-includes=${prefix}/include/postgresql82/ \
				--with-postgres-libraries=${prefix}/lib/postgresql82/
}

variant postgresql83 conflicts postgresql82 description {Build against postgresql83} {
	depends_lib-append	port:postgresql83
	configure.args-append	--with-postgres-includes=${prefix}/include/postgresql83/ \
				--with-postgres-libraries=${prefix}/lib/postgresql83/
}

pre-configure {
    if {![variant_isset postgresql83] && ![variant_isset postgresql82]} {
	return -code error "You have to choose either +postgresql82 or +postgresql83"
    }
}

post-configure {
	reinplace "s|PY_LIB_DIR = \$(prefix)|\
		PY_LIB_DIR = ${destroot}${prefix}|g" ${worksrcpath}/Makefile
	reinplace "s|PY_MOD_DIR = \$(exec_prefix)|\
		PY_MOD_DIR = ${destroot}${prefix}|g" ${worksrcpath}/Makefile
	reinplace "s|@echo 'Installing shared modules...'|\
		install -m 755 -d \$(PY_MOD_DIR)|g" ${worksrcpath}/Makefile
}

build.target

post-destroot {
	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}/examples
	xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING RELEASE-1.0 CREDITS \
		SUCCESS ChangeLog VERSION NEWS README FAQ INSTALL TODO \
		doc/python-taylor.txt ${destroot}${prefix}/share/doc/${name}
	xinstall -m 644 -W ${worksrcpath}/doc/examples binary.py bool.py \
		commit.py copy_from.py copy_from2.py copy_to.py dictfetch.py \
		dt.py first.py integrity.py notify.py oid.py somehackers.jpg \
		threads.py usercast.py whereareyou.jpg work.py \
		${destroot}${prefix}/share/doc/${name}/examples
	file rename ${destroot}${prefix}/lib/python2.4/site-packages/psycopgmodule.so ${destroot}${prefix}/lib/python2.4/site-packages/psycopg.so
}
