%define _zope2_pythonlibs %{_var}/lib/Zope2/lib/python
%define _zope2_installdir %{_var}/lib/Zope2/Products
%define _product ZPsycopgDA
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: 5%{?_dist_release}
License: GNU GPL2
URL: http://initd.org/software/initd/psycopg
Source0: http://initd.org/pub/software/psycopg/psycopg-%{version}.tar.gz
Patch0: psycopg-1.1.21-DA.patch
Patch1: psycopg-1.1.21-DABase.patch
BuildRequires: python-devel
BuildRequires: postgresql-devel
BuildRequires: python-egenix-mx-base
Requires: python
Requires: postgresql-libs
BuildRoot: %{_tmppath}/psycopg-%{version}-root
Distribution: Vine Linux
Vendor: Project Vine
Packager: owa

%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 %{_product}
Summary: ZPsycopgDA is a PostgreSQL database adapter product for Zope
Group: Development/Web Applications
Requires: %{name} == %{version}
Requires: Zope2-zserver >= 2.12
Provides: %{_product}
Obsoletes: Zope-%{_product}

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


%prep
%setup -q -n psycopg-%{version}
%patch0 -p1 -b .DA
%patch1 -p1 -b .DABase


%build
%configure \
	--with-postgres-libraries=%{_libdir} \
	--with-postgres-includes=%{_includedir}/pgsql \
	--with-mxdatetime-includes=%{python_sitearch}/mx/DateTime/mxDateTime  \
	--with-zope=%{_libdir}/Zope2 \
	;
make


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{python_sitearch}
install -m 755 psycopgmodule.so $RPM_BUILD_ROOT%{python_sitearch}
mkdir -p $RPM_BUILD_ROOT%{_zope2_pythonlibs}
ln -sf %{python_sitearch}/psycopgmodule.so $RPM_BUILD_ROOT%{_zope2_pythonlibs}

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


%clean
rm -rf $RPM_BUILD_ROOT


%preun %{_product}
if [ $1 = 0 ]; then
	rm -rf %{_zope2_installdir}/%{_product}/*.pyc
fi


%files
%defattr(-,root,root)
%{python_sitearch}/psycopgmodule.so

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

%files %{_product}
%defattr(-,Zope2,Zope2)
%{_zope2_pythonlibs}/psycopgmodule.so
%{_zope2_installdir}/%{_product}


%changelog
* Wed Dec 15 2010 Shu KONNO <owa@bg.wakwak.com> 1.1.21-5
- added psycopg-1.1.21-DA.patch
- added psycopg-1.1.21-DABase.patch
- rename sub-package: Zope-%{_product} => %{name}-%{_product}

* 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

