File python-micawber.spec of Package python-micawber

%if 0%{?fedora} < 28
%global with_python2 1
%endif

%if 0%{?fedora} >= 22
%global with_python3 1
%endif

%define author coleifer
%define unmangled_name micawber

Summary: A small library for extracting rich content from urls
Name: python-%{unmangled_name}
Version: 0.5.4
Release: 1%{?dist}
Source0: https://github.com/%{author}/%{unmangled_name}/archive/%{version}/%{unmangled_name}-%{version}.tar.gz
License: MIT
Group: Development/Libraries
Prefix: %{_prefix}
BuildArch: noarch
%if 0%{?with_python2}
BuildRequires: python2-devel
BuildRequires: python-setuptools
BuildRequires: python-django
BuildRequires: python-beautifulsoup4
%endif
%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-django
BuildRequires: python3-beautifulsoup4
%endif
Vendor: Charles Leifer <coleifer@gmail.com>
Url: http://github.com/coleifer/micawber/

%description
micawber supplies a few methods for retrieving rich metadata about a variety of
links, such as links to youtube videos.  micawber also provides functions for
parsing blocks of text and html and replacing links to videos with rich embedded
content.

%if 0%{?with_python2}
%package -n python2-%{unmangled_name}
Summary: A small library for extracting rich content from urls
Group: Development/Libraries
%{?python_provide:%python_provide python2-%{unmangled_name}}

%description -n python2-%{unmangled_name}
micawber supplies a few methods for retrieving rich metadata about a variety of
links, such as links to youtube videos.  micawber also provides functions for
parsing blocks of text and html and replacing links to videos with rich embedded
content.

This package contains the python2 version of this module.
%endif

%if 0%{?with_python3}
%package -n python3-%{unmangled_name}
Summary: A small library for extracting rich content from urls
Group: Development/Libraries
%{?python_provide:%python_provide python3-%{unmangled_name}}

%description -n python3-%{unmangled_name}
micawber supplies a few methods for retrieving rich metadata about a variety of
links, such as links to youtube videos.  micawber also provides functions for
parsing blocks of text and html and replacing links to videos with rich embedded
content.

This package contains the python3 version of this module.
%endif

%prep
%setup -n %{unmangled_name}-%{version}
%{__mv} examples micawber/examples

%build
%if 0%{?with_python2}
%py2_build
%endif
%if 0%{?with_python3}
%py3_build
%endif

%install
%if 0%{?with_python3}
%py3_install
%endif
%if 0%{?with_python2}
%py2_install
%endif

%check
%if 0%{?with_python2}
%{__python2} runtests.py
%endif

%if 0%{?with_python3}
%{__python3} runtests.py
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%if 0%{?with_python2}
%files -n python2-%{unmangled_name}
%doc *.rst
%{python2_sitelib}/%{unmangled_name}
%{python2_sitelib}/%{unmangled_name}-%{version}-py*.*.egg-info
%endif

%if 0%{?with_python3}
%files -n python3-%{unmangled_name}
%doc *.rst
%{python3_sitelib}/%{unmangled_name}
%{python3_sitelib}/%{unmangled_name}-%{version}-py*.*.egg-info
%endif