%global pypi_name jsonmodels
# Tests require invoke, which is only available for Fedora
%global use_tests 0%{?fedora:1}
# Python3 is not available on centos
%global is_install_py3 0%{?fedora:1}
Summary: Create Python structures that are converted to, or read from JSON
Name: python-jsonmodels
Version: 2.2
Release: 2%{?dist}
Source0: https://github.com/beregond/%{pypi_name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
License: BSD
BuildArch: noarch
Url: https://github.com/beregond/jsonmodels
BuildRequires: python2-devel
%if %{use_tests}
BuildRequires: python2-invoke
%endif
%if %{is_install_py3}
BuildRequires: python3-devel
BuildRequires: python3-invoke
%endif
%description
Models to make it easier to deal with structures that are converted to, or
read from JSON.
%package -n python2-%{pypi_name}
Summary: %summary
BuildRequires: python2-dateutil
BuildRequires: python2-pytest
%if %{use_tests}
BuildRequires: python2-pytest-cov
%endif
BuildRequires: python2-six
Requires: python2-dateutil
Requires: python2-six
%description -n python2-%{pypi_name}
Python 2 models to make it easier to deal with structures that are
converted to, or read from JSON.
%if %{is_install_py3}
%package -n python3-%{pypi_name}
Summary: %summary
BuildRequires: python3-dateutil
BuildRequires: python3-pytest
%if %{use_tests}
BuildRequires: python3-pytest-cov
%endif
BuildRequires: python3-six
Requires: python3-dateutil
Requires: python3-six
%description -n python3-%{pypi_name}
Python 3 models to make it easier to deal with structures that are
converted to, or read from JSON.
%endif
%prep
%setup -q -n %{pypi_name}-%{version}
%build
%py2_build
%if 0%{is_install_py3}
%py3_build
%endif
%install
%py2_install
%if 0%{is_install_py3}
%py3_install
%endif
%if %{use_tests}
%check
PYTHONPATH=$(pwd) %{__python2} setup.py test
%if 0%{?py3_build:1}
PYTHONPATH=$(pwd) %{__python3} setup.py test
%endif
%endif
%files -n python2-%{pypi_name}
%license LICENSE
%doc README.rst
%{python2_sitelib}/%{pypi_name}-%{version}-py%{python2_version}.egg-info
%{python2_sitelib}/%{pypi_name}/
%if %{is_install_py3}
%files -n python3-%{pypi_name}
%license LICENSE
%doc README.rst
%{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info
%{python3_sitelib}/%{pypi_name}/
%endif
%changelog
* Fri Jan 19 2018 Iryna Shcherbina <ishcherb@redhat.com> - 2.2-2
- Update Python 2 dependency declarations to new packaging standards
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)
* Wed Nov 15 2017 Omer Anson <oaanson@gmail.com> 2.2-1
- Fix use_tests and is_install_py3 conditions
- Initial release