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

%define _lxml lxml
Summary: lxml is a Pythonic binding for the libxml2 and libxslt libraries
Summary(ja): lxml は libxml2 と libxslt の Python バインディングです
Name: python-%{_lxml}
Group: Development/Libraries
Version: 3.8.0
Release: 1%{?_dist_release}
License: BSD
URL: http://codespeak.net/lxml
#URL: http://pypi.python.org/pypi/lxml
Source: http://pypi.python.org/packages/source/l/%{_lxml}/%{_lxml}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Vendor: Project Vine
Distribution: Vine Linux

BuildRequires: libxml2-devel >= 2.6.21
BuildRequires: libxslt-devel >= 1.1.15
BuildRequires: python-devel >= 2.3
BuildRequires: python3-devel
BuildRequires: python-pyrex

%description
lxml is a Pythonic binding for the libxml2_ and libxslt_ libraries.  It is
unique in that it combines the speed and feature completeness of these
libraries with the simplicity of a native Python API, mostly compatible but
superior to the well-known ElementTree_ API.  See the introduction_ for more
information about background and goals.

%package -n python3-lxml
Summary: lxml is a Pythonic binding for the libxml2 and libxslt libraries
Summary(ja): lxml は libxml2 と libxslt の Python バインディングです
Group: Development/Libraries

%description -n python3-lxml
lxml is a Pythonic binding for the libxml2_ and libxslt_ libraries.  It is
unique in that it combines the speed and feature completeness of these
libraries with the simplicity of a native Python API, mostly compatible but
superior to the well-known ElementTree_ API.  See the introduction_ for more
information about background and goals.

%prep
%setup -q -T -c -n %{_lxml}-%{version}

tar xvf %{SOURCE0}
mv %{_lxml}-%{version} py2

cp -a py2 py3

%build
pushd py2
%{__python} setup.py build
popd

pushd py3
python3 setup.py build
popd

%install
rm -rf $RPM_BUILD_ROOT

pushd py2
%{__python} setup.py install --root=$RPM_BUILD_ROOT
popd

pushd py3
python3 setup.py install --root=$RPM_BUILD_ROOT
popd

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc py2/CHANGES.txt py2/CREDITS.txt py2/LICENSES.txt py2/README.* py2/TODO.txt
%doc py2/doc
%{python_sitearch}/%{_lxml}
%{python_sitearch}/%{_lxml}-*-info

%files -n python3-lxml
%defattr(-,root,root)
%doc py3/CHANGES.txt py3/CREDITS.txt py3/LICENSES.txt py3/README.* py3/TODO.txt
%doc py3/doc
%{python3_sitearch}/%{_lxml}
%{python3_sitearch}/%{_lxml}-*-info

%changelog
* Sat Sep 09 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.8.0-1
- new upstream release.
- added python3 support.

* Sun Jan 12 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.2.6-4
- rebuild with VineSeed environment

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

* Wed Mar 10 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 2.2.6-2
- change required version of libxml2-devel for Vine Plus/5
  (2.7.2 or later is recomended, but works with 2.6.21 or later)

* Sun Mar 07 2010 Shu KONNO <owa@bg.wakwak.com> 2.2.6-1
- initial build for vine linux

