%global srcname adal
%global common_description The ADAL for Python library makes it easy for python applications to\
authenticate to AAD in order to access AAD protected web resources.
%global _with_python2 0%{?rhel} || 0%{?fedora} <= 29
%global py2_prefix %{?rhel:python}%{?fedora:python2}
%global _with_py2_tests 1
%global _with_python3 1
# httpretty library is not available for Python 3 in EL
%global _with_py3_tests 0%{?fedora}
Name: python-%{srcname}
Version: 1.2.0
Release: 1%{?dist}
Summary: ADAL for Python
License: MIT
URL: https://github.com/AzureAD/azure-activedirectory-library-for-python
Source0: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
# Fix tests with httpretty >= 0.9.0
Patch0: %{name}-1.2.0-tests.patch
%if 0%{?_with_python2}
BuildRequires: %{py2_prefix}-devel
BuildRequires: %{py2_prefix}-setuptools
%if 0%{?_with_py2_tests}
BuildRequires: %{py2_prefix}-cryptography
BuildRequires: %{py2_prefix}-dateutil
BuildRequires: %{py2_prefix}-httpretty
BuildRequires: %{py2_prefix}-jwt
BuildRequires: %{py2_prefix}-mock
BuildRequires: %{py2_prefix}-requests
BuildRequires: %{?!rhel:%{py2_prefix}-}pytest
%endif
%endif
%if 0%{?_with_python3}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
%if 0%{?_with_py3_tests}
BuildRequires: python%{python3_pkgversion}-cryptography
BuildRequires: python%{python3_pkgversion}-dateutil
BuildRequires: python%{python3_pkgversion}-httpretty
BuildRequires: python%{python3_pkgversion}-jwt
BuildRequires: python%{python3_pkgversion}-requests
BuildRequires: python%{python3_pkgversion}-pytest
%endif
%endif
BuildArch: noarch
%description
%{common_description}
%if 0%{?_with_python2}
%package -n python2-%{srcname}
Summary: %{summary}
Requires: %{py2_prefix}-cryptography
Requires: %{py2_prefix}-dateutil
Requires: %{py2_prefix}-jwt
Requires: %{py2_prefix}-requests
%{?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}-cryptography
Requires: python%{python3_pkgversion}-dateutil
Requires: python%{python3_pkgversion}-jwt
Requires: python%{python3_pkgversion}-requests
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}
%description -n python%{python3_pkgversion}-%{srcname}
%{common_description}
%endif
%prep
%autosetup -p0 -n azure-activedirectory-library-for-python-%{version}
%build
%if 0%{?_with_python2}
%py2_build
%endif
%if 0%{?_with_python3}
%py3_build
%endif
%install
%if 0%{?_with_python2}
%py2_install
%endif
%if 0%{?_with_python3}
%py3_install
%endif
%check
%if 0%{?_with_python2} && 0%{?_with_py2_tests}
py.test-%{python2_version}
%endif
%if 0%{?_with_python3} && 0%{?_with_py3_tests}
py.test-%{python3_version}
%endif
%if 0%{?_with_python2}
%files -n python2-%{srcname}
%doc README.md
%license LICENSE
%{python2_sitelib}/*
%endif
%if 0%{?_with_python3}
%files -n python%{python3_pkgversion}-%{srcname}
%doc README.md
%license LICENSE
%{python3_sitelib}/*
%endif
%changelog
* Sat Nov 10 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 1.2.0-1
- Update to 1.2.0
- Enable Python 3 support for EL