# invoke with "--with tests" to enable tests, currently disabled
# as we need to package both wsgi_intercept and pytest-localserver
# for them to work. Will also need BR: pystest once the two
# above packages exist in Fedora

%global sum Synchronize calendars and contacts
%global srcname vdirsyncer
# Share doc between python- and python3-
%global _docdir_fmt %{name}

Name:       vdirsyncer
Version:    0.16.7
Release:    1%{?git_tag}%{?dist}
Summary:    %{sum}

License:    BSD
URL:        https://github.com/untitaker/%{name}
#Source0:    %pypi_source
Source0:    vdirsyncer-0.16.7.tar.gz

BuildArch:  noarch
Obsoletes:  python2-%{srcname} <= 0.12.1

BuildRequires:  python3-atomicwrites >= 0.1.7
BuildRequires:  python3-click >= 5.0
BuildRequires:  python3-click-log >= 0.3
BuildRequires:  python3-click-threading >= 0.4.0
BuildRequires:  python3-devel
BuildRequires:  python3-icalendar
BuildRequires:  python3-lxml
BuildRequires:  python3-requests >= 2.10
BuildRequires:  python3-requests-oauthlib
BuildRequires:  python3-requests-toolbelt >= 0.4.0
BuildRequires:  python3-setuptools
BuildRequires:  python3-setuptools_scm
BuildRequires:  python3-sphinx
BuildRequires:  python3-sphinx_rtd_theme

Requires:       python3-atomicwrites >= 0.1.7
Requires:       python3-click >= 5.0
Requires:       python3-click-log >= 0.3
Requires:       python3-click-threading >= 0.4.0
Requires:       python3-icalendar
Requires:       python3-lxml >= 3.1
Requires:       python3-requests >= 2.4.1
Requires:       python3-requests-oauthlib
Requires:       python3-requests-toolbelt >= 0.4.0
Requires:       python3-vdirsyncer = %{version}
Requires:       sqlite

%description
vdirsyncer synchronizes your calendars and address books between two entities.
The supported protocols are CalDAV, CardDAV, arbitrary HTTP resources and some
more.

It aims to be for CalDAV and CardDAV what OfflineIMAP is for IMAP.

%package -n python3-%{srcname}
Summary:        %{sum}
%{?python_provide:%python_provide python3-%{srcname}}

Requires:       python3-atomicwrites >= 0.1.7
Requires:       python3-click >= 5.0
Requires:       python3-click-log >= 0.3
Requires:       python3-click-threading >= 0.4.0
Requires:       python3-icalendar
Requires:       python3-lxml >= 3.1
Requires:       python3-requests >= 2.4.1
Requires:       python3-requests-oauthlib
Requires:       python3-requests-toolbelt >= 0.4.0

%description -n python3-%{srcname}
vdirsyncer synchronizes your calendars and address books between two entities.
The supported protocols are CalDAV, CardDAV, arbitrary HTTP resources and some
more.

It aims to be for CalDAV and CardDAV what OfflineIMAP is for IMAP.
This package contains the python3 modules.

%package doc
Summary:        Documentation for vdirsyncer

%description doc
The vdirsyncer-doc package provides all the documentation
for the vdirsyncer calendar/address-book synchronization utility.

%prep
%setup -q

%build
%py3_build

# Custom sphinx docs need to import vdirsyncer classes from the untarred
# source tree
export PYTHONPATH=`pwd`
cd docs
# NOT using smp_mflags because sphinx cannot really cope with it
# i.e. one out of 20 builds will misteriously fail
make SPHINXBUILD=sphinx-build-3 man html text
cd ..
unset PYTHONPATH
# Remove extra copy of text docs
rm -vrf docs/_build/html/_sources
rm -fv docs/_build/html/{.buildinfo,objects.inv}


%install
%py3_install

install -d "$RPM_BUILD_ROOT%{_mandir}/man1"
cp -r docs/_build/man/%{name}.1 "$RPM_BUILD_ROOT%{_mandir}/man1"

%check
%if %{with tests}
sh build.sh tests
%endif

%files -n python3-%{srcname}
%license LICENSE
%doc AUTHORS.rst README.rst CONTRIBUTING.rst
%{python3_sitelib}/*

%files
%license LICENSE
%{_bindir}/vdirsyncer
%{_mandir}/man1/%{name}.1.*

# Still one rpmlint warning due to BZ 1107813
# W: wrong-file-end-of-line-encoding /usr/share/doc/vdirsyncer-doc/html/_static/jquery.js
%files doc
%doc docs/_build/html docs/_build/text

%changelog
* Thu Nov 15 2018 Timothée Floure <fnux@fedoraproject.org> - 0.16.7-1
- New upstream release
- Use the proper pypi_source macro to define the source tag

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.16.3-3
- Rebuilt for Python 3.7

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Tue Oct 03 2017 Michele Baldessari <michele@acksyn.org> - 0.16.3-1
- New upstream

* Thu Aug 24 2017 Michele Baldessari <michele@acksyn.org> - 0.16.2-1
- New upstream

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Mon Jul 10 2017 Michele Baldessari <michele@acksyn.org> - 0.16.0-1
- New upstream
- License is now BSD
- Require sqlite3

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.14.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Sun Jan 08 2017 Michele Baldessari <michele@acksyn.org> - 0.14.1-1
- New upstream

* Wed Dec 28 2016 Michele Baldessari <michele@acksyn.org> - 0.14.0-1
- New upstream
- Since 0.13.0 there is no longer python2 support, so drop it and obsolete python2-vdirsyncer

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 0.12.1-2
- Rebuild for Python 3.6

* Sun Sep 04 2016 Michele Baldessari <michele@acksyn.org> - 0.12.1-1
- New upstream

* Mon Aug 01 2016 Michele Baldessari <michele@acksyn.org> - 0.11.3-1
- New upstream

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.11.2-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Sun Jun 19 2016 Michele Baldessari <michele@acksyn.org> - 0.11.2-2
- Bump python-click-threading requirement

* Fri Jun 17 2016 Michele Baldessari <michele@acksyn.org> - 0.11.2-1
- New upstream

* Mon May 23 2016 Michele Baldessari <michele@acksyn.org> - 0.11.0-2
- Add requests-oauthlib to requires to get google integration

* Sun May 22 2016 Michele Baldessari <michele@acksyn.org> - 0.11.0-1
- New upstream (BZ#1329867)
- Split the package in python{2,3}-vdirsyncer containing the python modules and
  vdirsyncer containing the binary (needs the python3-modules)
- Add a python2 vdirsyncer module (BZ#1323555)

* Tue May 03 2016 Michele Baldessari <michele@acksyn.org> - 0.10.0-1
- New upstream

* Wed Mar 23 2016 Michele Baldessari <michele@acksyn.org> - 0.9.3-1
- New upstream

* Mon Mar 14 2016 Michele Baldessari <michele@acksyn.org> - 0.9.2-1
- New upstream
- Fix up some requires versioning

* Tue Feb 16 2016 Michele Baldessari <michele@acksyn.org> - 0.9.0-1
- New upstream

* Sat Feb 13 2016 Michele Baldessari <michele@acksyn.org> - 0.8.1-2
- Switch to python3 by default

* Fri Feb 12 2016 Michele Baldessari <michele@acksyn.org> - 0.8.1-1
- New upstream (requires python-click-{log,threading})

* Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Sun Jan 24 2016 Michele Baldessari <michele@acksyn.org> - 0.7.5-1
- New upstream, requires 0.5.0 python-requests-toolbelt

* Sat Nov 28 2015 Michele Baldessari <michele@acksyn.org> - 0.7.3-1
- New upstream (BZ 1275860)

* Sun Sep 13 2015 Michele Baldessari <michele@acksyn.org> - 0.6.0-2
- Add python-atomicwrites requires (BZ 1262597)

* Thu Aug 06 2015 Ben Boeckel <mathstuf@gmail.com> - 0.6.0-1
- Update to 0.6.0
- Use %%license
- Use PyPI tarball (see setup.py)

* Mon Jul 06 2015 Michele Baldessari <michele@acksyn.org> - 0.5.2-2
- Fix FTBFS (BZ#1046338)
* Tue Jun 16 2015 Michele Baldessari <michele@acksyn.org> - 0.5.2-1
- Update to 0.5.2
- Drop doc build patch
* Wed Jun 03 2015 Michele Baldessari <michele@acksyn.org> - 0.5.1-1
- Update to 0.5.1
- Drop system-urllib3.patch

* Fri Mar 13 2015 Michele Baldessari <michele@acksyn.org> - 0.4.4-1
- Update to 0.4.4

* Mon Mar 02 2015 Michele Baldessari <michele@redhat.com> - 0.4.3-5
- Disable python3 for now until khal supports it

* Sun Mar 01 2015 Michele Baldessari <michele@redhat.com> - 0.4.3-4
- Port to python3

* Sun Mar 01 2015 Michele Baldessari <michele@redhat.com> - 0.4.3-3
- Split out a -doc subpackage as fedora-review complained

* Sat Feb 28 2015 Michele Baldessari <michele@redhat.com> - 0.4.3-2
- Conditional test builds

* Mon Feb 23 2015 Michele Baldessari <michele@redhat.com> - 0.4.3-1
- New upstream

* Wed Feb 11 2015 Michele Baldessari <michele@redhat.com> - 0.4.2-3
- Add html and text documentation

* Wed Feb 04 2015 Michele Baldessari <michele@redhat.com> - 0.4.2-2
- Add python-atomicwrites dependency

* Tue Feb 03 2015 Michele Baldessari <michele@redhat.com> - 0.4.2-1
- New upstream

* Mon Jan 05 2015 Michele Baldessari <michele@redhat.com> - 0.4.0-2
- Force use of system urllib3

* Mon Jan 05 2015 Michele Baldessari <michele@redhat.com> - 0.4.0-1
- New upstream

* Mon Jan 05 2015 Michele Baldessari <michele@redhat.com> - 0.3.4-2
- Added python-icalendar and python-click Requires

* Mon Dec 15 2014 Michele Baldessari <michele@redhat.com> - 0.3.4-1
- New upstream

* Wed Oct 01 2014 Michele Baldessari <michele@redhat.com> - 0.3.0-1
- Initial packaging
