File python-UkPostcodeParser.spec of Package python-UkPostcodeParser

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

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

%define unmangled_name UkPostcodeParser

Summary: UK Postcode parser
Name: python-%{unmangled_name}
Version: 1.0.3
Release: 1
Source0: https://pypi.python.org/packages/source/U/%{unmangled_name}/%{unmangled_name}-%{version}.tar.gz
License: MIT
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Prefix: %{_prefix}
BuildArch: noarch
Vendor: Simon Brunning <simon@brunningonline.net>
Url: https://github.com/hamstah/ukpostcodeparser
BuildRequires: python2-devel
BuildRequires: python-setuptools
%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
%endif

%description
UK Postcode parser.

Original code by Simon Brunning <simon@brunningonline.net>

Taken from:
http://www.brunningonline.net/simon/blog/archives/001292.html

%if 0%{?with_python2}
%package -n python2-%{unmangled_name}
Summary: UK Postcode parser
Group: Development/Libraries
%{?python_provide:%python_provide python2-%{unmangled_name}}

%description -n python2-%{unmangled_name}
UK Postcode parser.

Original code by Simon Brunning <simon@brunningonline.net>

Taken from:
http://www.brunningonline.net/simon/blog/archives/001292.html

This package contains the python2 version of this module.

%endif

%if 0%{?with_python3}
%package -n python3-%{unmangled_name}
Summary: UK Postcode parser
Group: Development/Libraries
%{?python_provide:%python_provide python3-%{unmangled_name}}

%description -n python3-%{unmangled_name}
UK Postcode parser.

Original code by Simon Brunning <simon@brunningonline.net>

Taken from:
http://www.brunningonline.net/simon/blog/archives/001292.html

This package contains the python3 version of this module.

%endif

%prep
%setup -n %{unmangled_name}-%{version}

%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} %{py_setup} test
%endif

%if 0%{?with_python3}
%{__python3} %{py_setup} test
%endif

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


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