%{!?python3_sitearch: %define python3_sitearch %(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}

Name: python3-pycairo
Summary: Python3 bindings for the cairo library
Summary(ja): cairo ライブラリの Python3 バインディング
Version: 1.10.0
Release: 2%{?_dist_release}

Group: Development/Languages
License: LGPLv2
URL: http://cairographics.org/pycairo

Source: http://cairographics.org/releases/pycairo-%{version}.tar.bz2

# patch from http://www.linuxfromscratch.org/blfs/view/svn/general/python-modules.html#pycairo
Patch0:	pycairo-1.10.0-waf_unpack-1.patch
Patch1:	pycairo-1.10.0-waf_python_3_4-1.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: cairo-devel >= 1.10.0
BuildRequires: python3-devel >= 3.0
BuildRequires: pkgconfig
Requires: python3 >= 3.0
Requires: cairo >= 1.10.0

%description
Python3 bindings for the cairo library.

%package devel
Summary: Libraries and headers for pycairo
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: cairo-devel >= 1.10.0
Requires: python3-devel >= 3.0

%description devel
This package contains files required to build wrappers for cairo add-on
libraries so that they interoperate with pycairo3.

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

# see http://www.linuxfromscratch.org/blfs/view/svn/general/python-modules.html#pycairo
%patch0 -p1 -b .unpack
wafdir=$(./waf unpack)
pushd $wafdir
%patch1 -p1 -b .py34
popd
unset wafdir

%build
export PYTHON=python3
./waf configure \
			--prefix=%{_prefix} \
			--libdir=%{_libdir}

./waf build

%install
rm -rf $RPM_BUILD_ROOT

DESTDIR=$RPM_BUILD_ROOT python3 ./waf install
find $RPM_BUILD_ROOT -name '*.la' | xargs rm -f

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING* INSTALL NEWS README
%{python3_sitearch}/cairo/

%files devel
%defattr(-,root,root,-)
%{_includedir}/pycairo/py3cairo.h
%{_libdir}/pkgconfig/py3cairo.pc

%changelog
* Mon Jan 12 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.10.0-2
- rebuild with python-3.4.2
- add Patch0 (pycairo-1.10.0-waf_unpack-1.patch)
- add Patch1 (pycairo-1.10.0-waf_python_3_4-1.patch)

* Sat Oct 26 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.10.0-1
- initial build

