Blob Blame Raw
%global pyname python-cloudflare
%global pkgname cloudflare

%if 0%{?rhel} && 0%{?rhel} <= 7
%bcond_with python3
%else
%bcond_without python3
%endif

%if 0%{?fedora} >= 30 || 0%{?rhel} >= 8
%bcond_with python2
%else
%bcond_without python2
%endif

Name:           python-%{pkgname}
Version:        2.6.0
Release:        1%{?dist}
Summary:        Python wrapper for the Cloudflare Client API v4

License:        MIT
URL:            https://pypi.python.org/pypi/%{pkgname}
Source0:        https://github.com/cloudflare/%{pyname}/archive/%{version}.tar.gz

# TODO: Remove this once jsonlines is packaged
Patch0:         remove-jsonlines.patch
Patch1:         remove-shebangs.patch
Patch2:         remove-examples.patch

BuildArch:      noarch

%if %{with python2}
BuildRequires:  python2-devel
BuildRequires:  python2-future
BuildRequires:  python2-requests
BuildRequires:  python2-setuptools

%if 0%{?fedora} > 27 || 0%{?rhel} >= 8
BuildRequires:  python2-pyyaml
%else
BuildRequires:  PyYAML
%endif
%endif

%if %{with python3}
BuildRequires:  python3-devel
BuildRequires:  python3-future
BuildRequires:  python3-PyYAML
BuildRequires:  python3-requests
BuildRequires:  python3-setuptools
%endif

BuildRequires:  sed

%description
Python wrapper library for the Cloudflare Client API v4.

%if %{with python2}
%package -n python2-%{pkgname}
Requires:       python2-future
Requires:       python2-requests

%if 0%{?fedora} > 27 || 0%{?rhel} >= 8
Requires:       python2-pyyaml
%else
Requires:       PyYAML
%endif

Summary:        %{summary}
%{?python_provide:%python_provide python2-%{pkgname}}

%description -n python2-%{pkgname}
Python wrapper library for the Cloudflare Client API v4.

This is the Python 2 version of the package.
%endif

%if %{with python3}
%package -n python3-%{pkgname}
Requires:       python3-future
Requires:       python3-PyYAML
Requires:       python3-requests

Summary:        %{summary}
%{?python_provide:%python_provide python3-%{pkgname}}

%description -n python3-%{pkgname}
Python wrapper library for the Cloudflare Client API v4.

This is the Python 3 version of the package.
%endif

%prep
%autosetup -p1 -n %{pyname}-%{version}
# Remove shebangs
sed -i -e '1!b' -e '\~^#!/usr/bin/env python~d' cli4/*.py

%build
%if %{with python2}
%py2_build
%endif

%if %{with python3}
%py3_build
%endif

%check
%if %{with python2}
%{__python2} setup.py test
%endif

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

%install
# Remove examples
rm -rf build/lib/examples

%if %{with python2}
%py2_install
%endif

%if %{with python3}
%py3_install
%endif

install -pD cli4/cli4.man %{buildroot}%{_mandir}/man1/cli4.1

%if %{with python2}
%files -n python2-%{pkgname}
%license LICENSE
%doc README.rst
%if ! %{with python3}
%{_bindir}/cli4
%doc %attr(0644,root,root) %{_mandir}/man1/cli4.1*
%endif
%{python2_sitelib}/cli4
%{python2_sitelib}/CloudFlare
%{python2_sitelib}/cloudflare-%{version}*.egg-info
%endif

%if %{with python3}
%files -n python3-%{pkgname}
%license LICENSE
%doc README.rst
%{_bindir}/cli4
%doc %attr(0644,root,root) %{_mandir}/man1/cli4.1*
%{python3_sitelib}/cli4
%{python3_sitelib}/CloudFlare
%{python3_sitelib}/cloudflare-%{version}*.egg-info
%endif

%changelog
* Fri Jan 31 2020 Felix Schwarz <felix.schwarz@oss.schwarz.eu> - 2.6.0-1
- Update to 2.6.0

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Mon Oct 07 2019 Eli Young <elyscape@gmail.com> - 2.3.0-5
- Support EPEL8 builds

* Thu Oct 03 2019 Miro Hron훾ok <mhroncok@redhat.com> - 2.3.0-4
- Rebuilt for Python 3.8.0rc1 (#1748018)

* Mon Aug 19 2019 Miro Hron훾ok <mhroncok@redhat.com> - 2.3.0-3
- Rebuilt for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Mon Jul 01 2019 Eli Young <elyscape@gmail.com> - 2.3.0-1
- Update to 2.3.0 (#1712059)

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.0-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Thu Dec 13 2018 Eli Young <elyscape@gmail.com> - 2.1.0-11
- Remove Python 2 package in Fedora 30+ (#1658535)

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.0-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Fri Jul 06 2018 Eli Young <elyscape@gmail.com> - 2.1.0-9
- Simplify example removal

* Fri Jun 29 2018 Eli Young <elyscape@gmail.com> - 2.1.0-8
- Remove unnecessary shebangs

* Tue Jun 19 2018 Miro Hron훾ok <mhroncok@redhat.com> - 2.1.0-7
- Rebuilt for Python 3.7

* Tue Jun 19 2018 Miro Hron훾ok <mhroncok@redhat.com> - 2.1.0-6
- Rebuilt for Python 3.7

* Wed Apr 04 2018 Eli Young <elyscape@gmail.com> - 2.1.0-5
- Fix man page permissions

* Wed Apr 04 2018 Eli Young <elyscape@gmail.com> - 2.1.0-4
- Add cli4 man page

* Wed Apr 04 2018 Eli Young <elyscape@gmail.com> - 2.1.0-3
- Remove example scripts from egg info
- Remove unnecessary shebangs

* Wed Apr 04 2018 Eli Young <elyscape@gmail.com> - 2.1.0-2
- Fix python3 package dependencies (#1563427)

* Tue Mar 27 2018 Eli Young <elyscape@gmail.com> - 2.1.0-1
- Update to 2.1.0 (#1560758)

* Mon Feb 26 2018 Nick Bebout <nb@usi.edu> - 2.0.4-2
- Add python2- prefix where available

* Fri Feb 16 2018 Eli Young <elyscape@gmail.com> - 2.0.4-1
- Initial package (#1546297)