Blob Blame History Raw
# Workaround for epel versions where don't exists python2 macro
%{!?__python2: %global __python2 %{__python}}

%if 0%{?fedora} > 12 || 0%{?rhel} > 6
%global with_python3 1
%else
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
%endif

%global with_tests 1

Name:           python-cssselect
Version:        0.9.1
Release:        4%{?dist}
Group:          Development/Libraries
Summary:        Parses CSS3 Selectors and translates them to XPath 1.0

License:        BSD
URL:            http://packages.python.org/cssselect/
Source0:        http://pypi.python.org/packages/source/c/cssselect/cssselect-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python2-devel python-setuptools
%if 0%{?with_tests}
BuildRequires:  python-lxml
%endif # if with_tests
%if 0%{?with_python3}
BuildRequires:  python3-devel python3-setuptools
%if 0%{?with_tests}
BuildRequires:  python3-lxml
%endif # if with_tests
%endif # if with_python3

%description
Cssselect parses CSS3 Selectors and translates them to XPath 1.0 expressions. 
Such expressions can be used in lxml or another XPath engine to find the 
matching elements in an XML or HTML document.

%if 0%{?with_python3}
%package -n python3-cssselect
Group:          Development/Libraries
Summary:        Parses CSS3 Selectors and translates them to XPath 1.0

%description -n python3-cssselect
Cssselect parses CSS3 Selectors and translates them to XPath 1.0 expressions. 
Such expressions can be used in lxml or another XPath engine to find the 
matching elements in an XML or HTML document.
%endif # if with_python3

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

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!/usr/bin/python|#!%{__python3}|'
%endif # with_python3

find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python2}|'

%build
%{__python2} setup.py build

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif # with_python3

%check
%if 0%{?with_tests}
PYTHONPATH=$(pwd) %{__python2} cssselect/tests.py
%if 0%{?with_python3}
pushd %{py3dir}
PYTHONPATH=${py3dir} %{__python3} cssselect/tests.py
popd
%endif # with_python3
%endif # with_tests

%install
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
chmod 755 $RPM_BUILD_ROOT/%{python3_sitelib}/cssselect/tests.py
popd
%endif # with_python3

%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
chmod 755 $RPM_BUILD_ROOT/%{python_sitelib}/cssselect/tests.py

%files
%doc AUTHORS docs README.rst CHANGES LICENSE PKG-INFO
%{python_sitelib}/cssselect*

%if 0%{?with_python3}
%files -n python3-cssselect
%doc AUTHORS docs README.rst CHANGES LICENSE PKG-INFO
%{python3_sitelib}/cssselect*
%endif # with_python3

%changelog
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Thu May 15 2014 Bohuslav Kabrda <bkabrda@redhat.com> - 0.9.1-3
- Enable tests again.

* Wed May 14 2014 Bohuslav Kabrda <bkabrda@redhat.com> - 0.9.1-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4
- Bootstrap test running (circular dependency with python-lxml)

* Fri Jan 17 2014 Eduardo Echeverria <echevemaster@gmail.com> 0.9.1-1
- Update to latest upstream.
- although this package have py3 support, the resultant python3 package 
  doesn't existed, reason? On install section, py3 setup install must be first,
  if not, with every running of setup.py install, setup.py overwrite the files, 
  this behaviour has been fixed
- Workaround for python2 macro in epel versions
- use python2 macro instead of python

* Thu Jul 25 2013 Eric Smith <brouhaha@fedoraproject.org> 0.8-1
- Update to latest upstream.
- Added Python 3 support.
- Added EL6 support (uses Python 2.6 rather than 2.7).

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Fri Nov 09 2012 Kevin Fenzi <kevin@scrye.com> 0.7.1-3
- Add tests.

* Fri Nov 09 2012 Kevin Fenzi <kevin@scrye.com> 0.7.1-2
- Fixes from review. 

* Fri Nov 09 2012 Kevin Fenzi <kevin@scrye.com> 0.7.1-1
- Initial version for review