%define _python python%(python -c 'import sys;print(sys.version[0:3])')
%define _product ZPsycopgDA
%define _zope_instance %{_libdir}/zope/lib/python/Products

Summary: psycopg is a PostgreSQL database adapter for Python
Summary(ja): psycopg は Python の PostgreSQL 用データベースアダプタです
Name: python-psycopg
Group: Applications/Databases
Version: 1.1.21
Release: 4%{?_dist_release}
License: GNU GPL2
URL: http://initd.org/software/initd/psycopg
Source: http://initd.org/pub/software/psycopg/psycopg-%{version}.tar.gz
Distribution: Vine Linux
Vendor: Project Vine
BuildRoot: %{_tmppath}/psycopg-%{version}-root
BuildRequires: python-devel postgresql-devel python-egenix-mx-base
Requires: python postgresql-libs

%description
psycopg is a PostgreSQL database adapter for the Python programming
language (just like pygresql and popy.) It was written from scratch with
the aim of being very small and fast, and stable as a rock. The main
advantages of psycopg are that it supports the full Python DBAPI-2.0 and
being thread safe at level 2.

%package doc
Summary: Documentation for psycopg python PostgreSQL database adapter
Group: Applications/Databases

%description doc
Documenation and example files for the psycopg python PostgreSQL
database adapter.

%package -n Zope-%{_product}
Summary: ZPsycopgDA is a PostgreSQL database adapter product for Zope
Group: Development/Web Applications
Requires: python-psycopg == %{version}
Requires: Zope-zserver

%description -n Zope-%{_product}
ZPsycopgDA is a PostgreSQL database adapter product for Zope.

%prep
%setup -q -n psycopg-%{version}

%build
%configure \
	--with-python=%{_bindir}/%{_python} \
	--with-postgres-libraries=%{_libdir} \
	--with-postgres-includes=%{_includedir}/pgsql \
	--with-mxdatetime-includes=%{_libdir}/%{_python}/site-packages/mx/DateTime/mxDateTime  \
	--with-zope=%{_libdir}/zope

make

%install
mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_python}/site-packages
install -m 755 psycopgmodule.so $RPM_BUILD_ROOT%{_libdir}/%{_python}/site-packages

mkdir -p $RPM_BUILD_ROOT%{_zope_instance}
find %{_product} -name CVS | xargs rm -fr
cp -pR %{_product} $RPM_BUILD_ROOT%{_zope_instance}

%clean
rm -rf $RPM_BUILD_ROOT

%post
if [ -d /var/lib/zope/Products/%{_product} ]; then
	rm -rf /var/lib/zope/Products/%{_product}
fi

%files
%defattr(-,root,root)
%{_libdir}/%{_python}/site-packages/*.so

%files doc
%defattr(-,root,root)
%doc AUTHORS  COPYING  CREDITS  FAQ  INSTALL  NEWS  README  RELEASE-1.0  SUCCESS  TODO doc

%files -n Zope-%{_product}
%defattr(-,zope,zope)
%{_zope_instance}/%{_product}

%changelog
* Tue Feb 02 2010 Shu KONNO <owa@bg.wakwak.com> 1.1.21-4
- rebuild with python-2.6

* Wed Jul 08 2009 Shu KONNO <owa@bg.wakwak.com> 1.1.21-3
- rebuilt with postgresql-8.4.0

* Sun Jul 20 2008 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.21-2vl5
- rebuilt with python-2.5.2 

* Thu Jul 17 2008 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.21-1vl5
- applied new versioning policy and spec in utf-8

* Fri Oct 13 2006 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.21-0vl1
- update psycopg to 1.1.21
- changed install directory with %{_libdir}/zope/lib/python/Products/

* Sat May 28 2005 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.18-0vl1
- changed spec for vine seed

* Sun May 01 2005 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.18-uvl3
- added option "--with-postgres-libraries" to configure

* Mon Mar 21 2005 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.18-uvl2
- rebuilded with python 2.4

* Thu Mar 10 2005 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.18-uvl1
- updated psycopg to 1.1.18

* Tue Feb 15 2005 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.17-uvl1
- updated psycopg to 1.1.17

* Fri Jul 30 2004 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.15-uvl1
- updated psycopg to 1.1.15

* Mon May 24 2004 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.13-uvl1
- updated psycopg to 1.1.13

* Thu Apr 29 2004 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.11-uvl3
- rebuild

* Sat Apr 24 2004 Shu KONNO <owa@bg.wakwak.com> python-psycopg-1.1.11-uvl1
- renamed
- build with python-2.3.3-0vl1

* Sat Feb 28 2004 Shu KONNO <owa@bg.wakwak.com> python2.3-psycopg-1.1.10-uvl1
- changed package name

* Fri Nov 21 2003 Shu KONNO <owa@bg.wakwak.com> psycopg-1.1.10-py2.1_uvl1
- removed memory leak by adding some DECREFs (by Chris Douty)

* Sun Aug 31 2003 Shu KONNO <owa@bg.wakwak.com> psycopg-1.1.6-py2.1_uvl1

* Wed Jun 25 2003 Shu KONNO <owa@bg.wakwak.com> psycopg-1.1.5.1-py2.1_uvl1

* Wed Mar 5 2003 Shu KONNO <owa@bg.wakwak.com> psycopg-1.0.14-py2.1_0vp1

* Mon Jul 1 2002 Shu KONNO <owa@bg.wakwak.com> psycopg-1.0.9-0vp1
- created new

