%global srcname msrestazure
%global common_description %{summary}.
%global _with_python2 0%{?rhel} || 0%{?fedora} <= 29
%global py2_prefix %{?rhel:python}%{?fedora:python2}
# Some Python 3 libraries required by msrestazure are not available in EL
%global _with_python3 0%{?fedora}
# Tests require a more recent version of requests library than the one available
# in EL
%global _with_tests 0%{?fedora}
# EL is missing recommonmark library to build documentation
%global _with_doc 0%{?fedora}
%global pydoc_prefix %{?rhel:python}%{?fedora:python%{python3_pkgversion}}
%global sphinxbuild sphinx-build%{?fedora:-%{python3_version}}
%global adal_min_version 0.6.0
%global msrest_min_version 0.4.28
Name: python-%{srcname}
Version: 0.5.1
Release: 2%{?dist}
Summary: The runtime library "msrestazure" for AutoRest generated Python clients
License: MIT
URL: https://github.com/Azure/msrestazure-for-python
Source0: %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz
%if 0%{?_with_python2}
BuildRequires: %{py2_prefix}-devel
BuildRequires: %{py2_prefix}-setuptools
%if 0%{?_with_tests}
BuildRequires: %{py2_prefix}-adal >= %{adal_min_version}
BuildRequires: %{py2_prefix}-mock
BuildRequires: %{py2_prefix}-msrest >= %{msrest_min_version}
BuildRequires: %{?!rhel:%{py2_prefix}-}pytest
%if 0%{?fedora} <= 27
BuildRequires: python-httpretty
%else
BuildRequires: %{py2_prefix}-httpretty
%endif
%endif
%endif
%if 0%{?_with_python3}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
%if 0%{?_with_tests}
BuildRequires: python%{python3_pkgversion}-adal >= %{adal_min_version}
BuildRequires: python%{python3_pkgversion}-httpretty
BuildRequires: python%{python3_pkgversion}-msrest >= %{msrest_min_version}
BuildRequires: python%{python3_pkgversion}-pytest
%endif
%endif
%if 0%{?_with_doc}
BuildRequires: %{pydoc_prefix}-pip
BuildRequires: %{pydoc_prefix}-recommonmark
BuildRequires: %{pydoc_prefix}-sphinx
BuildRequires: %{pydoc_prefix}-sphinx_rtd_theme
%endif
BuildArch: noarch
%description
%{common_description}
%if 0%{?_with_python2}
%package -n python2-%{srcname}
Summary: %{summary}
Requires: %{py2_prefix}-adal >= %{adal_min_version}
Requires: %{py2_prefix}-msrest >= %{msrest_min_version}
%{?python_provide:%python_provide python2-%{srcname}}
%description -n python2-%{srcname}
%{common_description}
%endif
%if 0%{?_with_python3}
%package -n python%{python3_pkgversion}-%{srcname}
Summary: %{summary}
Requires: python%{python3_pkgversion}-adal >= %{adal_min_version}
Requires: python%{python3_pkgversion}-msrest >= %{msrest_min_version}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}
%description -n python%{python3_pkgversion}-%{srcname}
%{common_description}
%endif
%if 0%{?_with_doc}
%package doc
Summary: Documentation for %{name}
%description doc
This package provides documentation for %{name}.
%endif
%prep
%autosetup -n %{srcname}-for-python-%{version}
%build
%if 0%{?_with_python2}
%py2_build
%endif
%if 0%{?_with_python3}
%py3_build
%endif
%if 0%{?_with_doc}
pushd doc/
%{sphinxbuild} -b html -d _build/doctrees/ . _build/html/
rm _build/html/.buildinfo
popd
%endif
%install
%if 0%{?_with_python2}
%py2_install
%endif
%if 0%{?_with_python3}
%py3_install
%endif
%check
%if 0%{_with_tests}
%if 0%{?_with_python2}
py.test-%{python2_version}
%endif
%if 0%{?_with_python3}
py.test-%{python3_version}
%endif
%endif
%if 0%{?_with_python2}
%files -n python2-%{srcname}
%doc README.rst
%license LICENSE.md
%{python2_sitelib}/%{srcname}/
%{python2_sitelib}/%{srcname}-*.egg-info/
%endif
%if 0%{?_with_python3}
%files -n python%{python3_pkgversion}-%{srcname}
%doc README.rst
%license LICENSE.md
%{python3_sitelib}/%{srcname}/
%{python3_sitelib}/%{srcname}-*.egg-info/
%endif
%if 0%{?_with_doc}
%files doc
%doc doc/_build/html/
%license LICENSE.md
%endif
%changelog
* Tue Nov 13 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 0.5.1-2
- Rebuild for python-msrest dependency fix update
* Sun Nov 11 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 0.5.1-1
- Update to 0.5.1
- Build documentation