%define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")

%{!?python3:%global __python3 /usr/bin/python3}
%{!?python3_inc:%global python3_inc %(%{__python3} -c "from distutils.sysconfig import get_python_inc; print(get_python_inc(1))")}
%{!?python3_sitearch: %global python3_sitearch %(python3 -c "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib(1))")}
%{!?python3_sitelib: %global python3_sitelib %(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python3_version: %global python3_version %(python3 -c "import sys; sys.stdout.write(sys.version[:3])")}


%global srcname cssutils

Summary: CSS Cascading Style Sheets library for Python
Summary(ja): Python 用 CSS カスケーディング・スタイル・シート ライブラリ
Name: python-cssutils
Version: 1.0.1
Release: 1%{?_dist_release}
License: LGPLv3+
Group: Development/Libraries
URL: http://cthedot.de/cssutils/
Source0: https://pypi.python.org/packages/source/c/cssutils/cssutils-1.0.1.tar.gz
Provides: python3-%{srcname} = %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
# Required at runtime for the css* executables
Requires: python-setuptools
BuildRequires: python-devel
BuildRequires: python-setuptools
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: dos2unix
BuildArch: noarch

Vendor: Project Vine
Distribution: Vine Linux

%description
A Python package to parse and build CSS Cascading Style Sheets. DOM only, not
any rendering facilities.

%description -l ja
CSS カスケーディング・スタイル・シートの作成と構文解析用の Pythonパッケージ
です。ただし DOM にのみ対応しており、レンダリングには対応していません。


%package doc
Summary: Documentation for the CSS Cascading Style Sheets library for Python
Summary(ja): Python 用 CSS カスケーディング・スタイル・シート ライブラリのドキュメント
Group: Applications/Documentation

%description doc
This is the documentation for python-cssutils, a Python package to parse and
build CSS Cascading Style Sheets.

%description doc -l ja
CSS カスケーディング・スタイル・シートの作成と構文解析用の Pythonパッケージ
である、python-cssutils のドキュメントです。


%package -n python3-%{srcname}
Summary:        %{sum}
Summary(ja):    Python3 用 CSS カスケーディング・スタイル・シート ライブラリ
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname}
A Python package to parse and build CSS Cascading Style Sheets. DOM only, not
any rendering facilities.

%description -n python3-%{srcname} -l ja
CSS カスケーディング・スタイル・シートの作成と構文解析用の Python3パッケージ
です。ただし DOM にのみ対応しており、レンダリングには対応していません。


%prep
%setup -qc
# Convert all CRLF files, keeping original timestamps
find . -type f -exec dos2unix -k {} \;
cp -pr %{srcname}-%{version}/examples .
cp -pr %{srcname}-%{version}/README.txt .
cp -pr %{srcname}-%{version}/COPYING .
mv %{srcname}-%{version} python2
cp -a python2 python3
find python3 -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python3}|'
find python2 -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python}|'


%build
pushd python2
%{__python} setup.py build
popd
pushd python3
%{__python3} setup.py build
popd


%install
%{__rm} -rf ${RPM_BUILD_ROOT}

pushd python2
%{__python} setup.py install \
    --single-version-externally-managed \
    -O1 \
    --skip-build \
    --root ${RPM_BUILD_ROOT}
popd

pushd python3
%{__python3} setup.py install \
    --single-version-externally-managed \
    -O1 \
    --skip-build \
    --root ${RPM_BUILD_ROOT}
popd


%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%files
%license COPYING
%doc README.txt
%{python_sitelib}/*

%files -n python3-%{srcname}
%license COPYING
%doc README.txt
%{python3_sitelib}/*
%{_bindir}/csscapture
%{_bindir}/csscombine
%{_bindir}/cssparse

%files doc
%defattr(-,root,root,-)
%doc docs/* examples/


%changelog
* Tue Jul 12 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.0.1-1
- new upstream release.

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

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

* Thu Aug 26 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.9.7-1.b3
- new upstream release

* Tue Aug 24 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.9.6-1
- new upstream release

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

* Sun Dec 14 2008 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.9.5.1-1
- initial build for Vine Linux based on fedora package

* Sat Nov 29 2008 Ignacio Vazquez-Abrams <ivazqueznet+rpm@gmail.com> - 0.9.5.1-4
- Rebuild for Python 2.6

* Fri Oct 10 2008 Matthias Saou <http://freshrpms.net/> 0.9.5.1-3
- Add missing python-setuptools BR, split off doc sub-package (mschwendt).

* Thu Oct  9 2008 Matthias Saou <http://freshrpms.net/> 0.9.5.1-2
- Update license, group, add python-setuptools requirement (mschwendt).

* Tue Aug 19 2008 Matthias Saou <http://freshrpms.net/> 0.9.5.1-1
- Update to 0.9.5.1.

* Fri Aug  8 2008 Matthias Saou <http://freshrpms.net/> 0.9.5-1
- Update to 0.9.5 final.

* Tue Jul 15 2008 Matthias Saou <http://freshrpms.net/> 0.9.5b2-0.2.rc2
- Convert CRLF end of lines.
- Patch out #!/... magic from python files meant to be included and not run.

* Tue Jul 15 2008 Matthias Saou <http://freshrpms.net/> 0.9.5b2-0.1.rc2
- Initial RPM release.

