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

%define pkg_release	2%{?_dist_release}

Summary: CSS Cascading Style Sheets library for Python
Summary(ja): Python 用 CSS カスケーディング・スタイル・シート ライブラリ
Name: python-cssutils
Version: 0.9.5.1
Release: %{pkg_release}
License: LGPLv3+
Group: Development/Libraries
URL: http://cthedot.de/cssutils/
Source: http://cssutils.googlecode.com/files/cssutils-%{version}.zip
Patch0: cssutils-0.9.5.1-nohashbang.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
# Required at runtime for the css* executables
Requires: python-setuptools
BuildRequires: python-devel
BuildRequires: python-setuptools
BuildArch: noarch

%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 のドキュメントです。


%prep
%setup -q -n cssutils-%{version}
%patch0 -p1
# Convert all CRLF files, keeping original timestamps
for FILE in `find . -type f -exec grep -Gl '\r\n' {} \;`; do
    tr -d '\r' < ${FILE} > ${FILE}.tmp
    touch -r ${FILE} ${FILE}.timestamp
    cat ${FILE}.tmp > ${FILE}
    touch -r ${FILE}.timestamp ${FILE}
    rm -f ${FILE}.timestamp ${FILE}.tmp
done


%build
%{__python} setup.py build


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


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


%files
# The sources have some 2755 mode directories (as of 0.9.5.1), fix here
%defattr(-,root,root,0755)
%doc CHANGELOG.txt COPYING* docs/ README.txt
%{_bindir}/csscapture
%{_bindir}/csscombine
%{_bindir}/cssparse
%{python_sitelib}/cssutils-*.egg-info/
%{python_sitelib}/cssutils/
%{python_sitelib}/encutils/
# This is a way too generic name!
%exclude %{python_sitelib}/tests/

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

%changelog
* 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.