%define _zope2_pythonlibs %{_var}/lib/Zope2/lib/python
%define _zope2_installdir %{_var}/lib/Zope2/Products
%define _product ZPsycopgDA
Summary: psycopg2 is a PostgreSQL database adapter for Python
Summary(ja): psycopg2 は Python の PostgreSQL 用データベースアダプタです
Name: python-psycopg2
Group: Applications/Databases
Version: 2.4
Release: 3%{?_dist_release}
License: LGPL or ZPL
Source: http://initd.org/pub/software/psycopg/psycopg2-%{version}.tar.gz
Patch0: psycopg2-2.2.2-DA.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. This is version 2, a complete rewrite of the original code to
provide new-style classes for connection and cursor objects and other
sweet candies. Like the original, psycopg 2 was written with the aim of
being very small and fast, and stable as a rock.

%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}

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


%prep
%setup -q -n psycopg2-%{version}
%patch0 -p1 -b .DA


%build
python setup.py build


%install
rm -rf $RPM_BUILD_ROOT
python setup.py install \
	--root $RPM_BUILD_ROOT \
	--install-lib %{python_sitearch} \
	;
mkdir -p $RPM_BUILD_ROOT%{_zope2_pythonlibs}
ln -sf %{python_sitearch}/psycopg2 $RPM_BUILD_ROOT%{_zope2_pythonlibs}
ln -sf %{python_sitearch}/psycopg2-%{version}-py%{pyver}.egg-info $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}/psycopg2
%{python_sitearch}/psycopg2-%{version}-py*.egg-info

%files doc
%defattr(-,root,root)
%doc AUTHORS INSTALL README doc

%files %{_product}
%defattr(-,Zope2,Zope2)
%{_zope2_pythonlibs}/psycopg2
%{_zope2_pythonlibs}/psycopg2-%{version}-py*.egg-info
%{_zope2_installdir}/%{_product}


%changelog
* Sun Jan 12 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.4-3
- rebuild with VineSeed environment

* Sun Feb 19 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.4-2
- rebuild with python-2.7.2

* Tue Apr 12 2011 Shu KONNO <owa@bg.wakwak.com> 2.4-1
- updated psycopg2 to 2.4

* Wed Dec 15 2010 Shu KONNO <owa@bg.wakwak.com> 2.2.2-1
- updated psycopg2 to 2.2.2
- added psycopg2-2.2.2-DA.patch

* Wed Feb 17 2010 Shu KONNO <owa@bg.wakwak.com> 2.0.13-1
- updated psycopg2 to 2.0.13

* Tue Feb 02 2010 Shu KONNO <owa@bg.wakwak.com> 2.0.11-2
- rebuild with python-2.6

* Wed Jul 08 2009 Shu KONNO <owa@bg.wakwak.com> 2.0.11-1
- updated psycopg2 to 2.0.11
- built with postgresql-8.4.0

* Mon May 04 2009 Shu KONNO <owa@bg.wakwak.com> python-psycopg2-2.0.10-1vl5
- updated psycopg2 to 2.0.10

* Wed Dec 31 2008 Shu KONNO <owa@bg.wakwak.com> python-psycopg2-2.0.8-1vl5
- updated psycopg2 to 2.0.8

* Thu Jul 17 2008 Shu KONNO <owa@bg.wakwak.com> python-psycopg2-2.0.7-1vl5
- packaged new

