## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 4;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global oldname weboob

Name: woob
Version: 3.6
Release: %autorelease -b 2
Summary: Web Outside Of Browser
Provides: %{oldname} = %{version}

# LGPL-3.0-or-later: woob
# AGPL-3.0-or-later: ~half of the modules (modules/*)
# WTFPL: woob/applications/video/image2xterm.py
# BSD-3-Clause: woob/tools/regex_helper.py
License: LGPL-3.0-or-later AND AGPL-3.0-or-later AND WTFPL AND BSD-3-Clause
URL: https://woob.tech/
Source: https://gitlab.com/%{name}/%{name}/-/archive/%{version}/%{name}-%{version}.tar.gz

# https://gitlab.com/woob/woob/-/merge_requests/858
Patch: 0001-pyproject.toml-Introduce-build-system-section.patch
Patch: 0002-pyproject.toml-relax-setuptools-dependency.patch
# https://gitlab.com/woob/woob/-/merge_requests/859
Patch: 0001-core-remove-shebang-from-non-executable-file.patch

BuildRequires: python3-devel
# Test dependencies:
BuildRequires: python3dist(pytest)
BuildRequires: python3dist(prettytable)

Requires: python3-%{name} = %{version}-%{release}
Requires: gnupg
Requires: python3dist(colorama)
Requires: python3dist(simplejson)
Recommends: python3-prettytable
Recommends: python3-termcolor
Recommends: python3-jose

BuildArch: noarch

%description
woob is a collection of applications able to interact with websites, without
requiring the user to open them in a browser. It also provides well-defined APIs
to talk to websites lacking one.

%package -n python3-%{name}
Summary: %{summary}
Provides: python3-%{oldname} = %{version}

%description -n python3-%{name}
Library which provides a Python standardized API and data models to access
websites.

%prep
%autosetup -v -p1 -n %{name}-%{version}

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files %{name} %{oldname}
install -m 0755 -vd %{buildroot}%{bash_completions_dir}
install -m 0644 -vp tools/%{name}_bash_completion %{buildroot}%{bash_completions_dir}/%{name}
install -m 0755 -vd %{buildroot}%{_mandir}/man1
install -m 0644 -vp man/*.1 %{buildroot}%{_mandir}/man1/

%check
# `test_table`: Cosmetic failure, should not impact the overall behavior
# `test_{ciphers,verify}`: require network
%pytest -k 'not test_table and not test_ciphers and not test_verify'

%files -f %{pyproject_files} -n python3-%{name}
%license COPYING.LESSER

%files
%doc README.rst
%{_bindir}/%{name}
%{_mandir}/man1/%{name}-*.1*
%{bash_completions_dir}/%{name}

%changelog
* Tue Oct 24 2023 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.6-5
- Ship the README as %%doc

* Tue Oct 24 2023 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.6-4
- Fix package license

* Sat Oct 21 2023 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.6-3
- Disable tests requirering networking

* Sat Oct 21 2023 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.6-2
- Rework package to respect packaging guidelines

* Sun Jun 18 2023 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.6-1
- Upgrade to 3.6

* Sun Apr 30 2023 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.5-1
- Upgrade to 3.5

* Sun Feb 26 2023 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.3.1-1
- Upgrade to 3.3.1

* Sat Jan 07 2023 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.1-1
- Upgrade to 3.1

* Fri Jan 21 2022 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.0-3
- Rationalize spec file

* Wed Oct 27 2021 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.0-2
- python rebuild

* Sun Apr 18 2021 Antoine Damhet <antoine.damhet@lse.epita.fr> - 3.0-1
- weboob -> woob + release 3.0

* Thu Mar 4 2021 Antoine Damhet <antoine.damhet@lse.epita.fr> - 2.0-1
- Initial Fedora package