%global srcname tinycss2
%if 0%{?fedora}
%bcond_without python3
%else
%bcond_with python3
%endif
%global py2_prefix python2
%global py3_prefix python%{python3_pkgversion}
Name: python-%{srcname}
Version: 0.6.1
Release: 2%{?dist}
Summary: Low-level CSS parser for Python
License: BSD
URL: https://pypi.python.org/pypi/%{srcname}/
Source0: https://files.pythonhosted.org/packages/source/t/%{srcname}/%{srcname}-%{version}.tar.gz
# Fedora does not ship pytest's flake8/isort modules
Patch0: %{name}-disable-flake8-isort-for-pytest.patch
BuildArch: noarch
BuildRequires: %{py2_prefix}-devel
BuildRequires: %{py2_prefix}-pytest
BuildRequires: %{py2_prefix}-pytest-cov
# required to run the tests
BuildRequires: %{py2_prefix}-webencodings >= 0.4
%if %{with python3}
BuildRequires: %{py3_prefix}-devel
BuildRequires: %{py3_prefix}-pytest
BuildRequires: %{py3_prefix}-pytest-cov
# required for testing
BuildRequires: %{py3_prefix}-webencodings >= 0.4
%endif # with python3
%description
tinycss2 is a modern, low-level CSS parser for Python. tinycss2 is a rewrite of
tinycss with a simpler API, based on the more recent CSS Syntax Level 3
specification.
%package -n %{py2_prefix}-%{srcname}
Summary: Low-level CSS parser for Python 2
Group: Development/Libraries
Requires: python2-webencodings >= 0.4
%{?python_provide:%python_provide %{py2_prefix}-%{srcname}}
%description -n %{py2_prefix}-%{srcname}
tinycss2 is a modern, low-level CSS parser for Python. tinycss2 is a rewrite of
tinycss with a simpler API, based on the more recent CSS Syntax Level 3
specification.
%if %{with python3}
%package -n %{py3_prefix}-%{srcname}
Summary: Low-level CSS parser for Python 3
Group: Development/Libraries
Requires: %{py3_prefix}-webencodings >= 0.4
%{?python_provide:%python_provide %{py3_prefix}-%{srcname}}
%description -n %{py3_prefix}-%{srcname}
tinycss2 is a modern, low-level CSS parser for Python. tinycss2 is a rewrite of
tinycss with a simpler API, based on the more recent CSS Syntax Level 3
specification.
%endif # with python3
%prep
%autosetup -n %{srcname}-%{version}
%build
%py2_build
%if %{with python3}
%py3_build
%endif # with python3
%install
%py2_install
%if %{with python3}
%py3_install
%endif # with python3
%check
%{__python2} -m pytest -v
# remove files which are only required for unit tests (including test.pyc/.pyo)
rm -rf %{buildroot}%{python2_sitelib}/%{srcname}/css-parsing-tests
rm -rf %{buildroot}%{python2_sitelib}/%{srcname}/test.py*
%if %{with python3}
%{__python3} -m pytest -v
rm -rf %{buildroot}%{python3_sitelib}/%{srcname}/css-parsing-tests
rm -rf %{buildroot}%{python3_sitelib}/%{srcname}/test.py
rm -rf %{buildroot}%{python3_sitelib}/%{srcname}/__pycache__/test.*.py?
%endif # with python3
%files -n %{py2_prefix}-%{srcname}
%license LICENSE
%doc CHANGES README.rst
%{python2_sitelib}/%{srcname}/
%{python2_sitelib}/%{srcname}-%{version}-py?.?.egg-info/
%if %{with python3}
%files -n %{py3_prefix}-%{srcname}
%license LICENSE
%doc CHANGES README.rst
%{python3_sitelib}/%{srcname}/
%{python3_sitelib}/%{srcname}-%{version}-py?.?.egg-info/
%endif # with python3
%changelog
* Sat Dec 16 2017 Felix Schwarz <fschwarz@fedoraproject.org> 0.6.1-2
- remove also generated bytecode for test.py in Python 3
- more specific files specification
* Tue Dec 12 2017 Felix Schwarz <fschwarz@fedoraproject.org> 0.6.1-1
- initial package