%global sum Python Twilio Helper Library

%global desc \
The Twilio REST SDK simplifies the process of making calls using the Twilio \
REST API. \
The Twilio REST API lets to you initiate outgoing calls, list previous calls, \
and much more.

%if 0%{?fedora}
%bcond_without python3
%else
%bcond_with python3
%endif

Name:           python-twilio
Version:        6.8.0
Release:        1%{?dist}
Summary:        %{sum}

License:        MIT
URL:            https://www.github.com/twilio/twilio-python
Source0:        https://github.com/twilio/twilio-python/archive/%{version}/%{name}-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python2-devel
BuildRequires:  %{py2_dist nose}
BuildRequires:  %{py2_dist pytz}
BuildRequires:  %{py2_dist six}
BuildRequires:  %{py2_dist mock}
BuildRequires:  %{py2_dist pyjwt}
BuildRequires:  %{py2_dist requests}

%if %{with python3}
BuildRequires:  python3-devel
BuildRequires:  %{py3_dist nose}
BuildRequires:  %{py3_dist pytz}
BuildRequires:  %{py3_dist six}
BuildRequires:  %{py3_dist mock}
BuildRequires:  %{py3_dist pyjwt}
BuildRequires:  %{py3_dist requests}
%endif # with python3

%description
%{desc}

#python2 subpackage
%package -n python2-twilio
Summary:        %{sum}

Requires:   %{py2_dist six}
Requires:   %{py2_dist requests}
Requires:   %{py2_dist pyjwt}
Requires:   %{py2_dist pytz}

%{?python_provide:%python_provide python2-twilio}

%description -n python2-twilio
%{desc}

#python3 subpackage
%if %{with python3}
%package -n python3-twilio
Summary:        %{sum}

Requires:   %{py3_dist six}
Requires:   %{py3_dist requests}
Requires:   %{py3_dist pyjwt}
Requires:   %{py3_dist pytz}

%{?python_provide:%python_provide python3-twilio}

%description -n python3-twilio
%{desc}

%endif # with python3


%prep
%autosetup -n twilio-python-%{version}

%build
%py2_build

%if %{with python3}
%py3_build
%endif # with python3


%install
%if %{with python3}
%py3_install
%endif # with python3

%py2_install


%check
%{__python2} setup.py test

%if %{with python3}
%{__python3} setup.py test
%endif


%files -n python2-twilio
%license LICENSE.md
%doc README.md examples
%{python2_sitelib}/*

%if %{with python3}
%files -n python3-twilio
%license LICENSE.md
%doc README.md examples
%{python3_sitelib}/*
%endif # with python3


%changelog
* Sat Oct 14 2017 Michael Cullen <michael@cullen-online.com> - 6.8.0-1
- Updated to a new version
- Dealt with some review comments
* Sun Oct 08 2017 Michael Cullen <michael@cullen-online.com> - 6.7.1-1
- Updated to a new version
* Sat Aug 26 2017 Michael Cullen <michael@cullen-online.com> - 6.6.0-2
- Various improvements to match example better
* Sat Aug 26 2017 Michael Cullen <michael@cullen-online.com> - 6.6.0-1
- Intial Packaging