## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    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 srcname aw-core

Name:           python-%{srcname}
Version:        0.5.17
Release:        %autorelease
Summary:        Core library for ActivityWatch

License:        MPL-2.0
URL:            https://github.com/ActivityWatch/aw-core
Source:         %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz

# https://github.com/ActivityWatch/aw-core/pull/127
Patch:          0001-Fix-aw-cli-command.patch

BuildArch:      noarch
BuildRequires:  python3-devel
BuildRequires:  help2man
BuildRequires:  python3dist(pytest)

%global _description %{expand:
Core library for ActivityWatch.}

%description %{_description}

%package -n python3-%{srcname}
Summary:    %{summary}

%description -n python3-%{srcname} %{_description}

%prep
%autosetup -p 1 -n %{srcname}-%{version}

# works also with 3.9 on f39 and 3.11 on f40, so unpinning
sed -ri 's/platformdirs = "3.10"/platformdirs = ">=3.9"/' pyproject.toml

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files -L {aw_cli,aw_core,aw_datastore,aw_transform,aw_query}
mkdir -p %{buildroot}%{_mandir}/man1
help2man --no-discard-stderr %{buildroot}%{_bindir}/aw-cli -o %{buildroot}%{_mandir}/man1/aw-cli.1

%check
%pytest

%files -n python3-%{srcname} -f %{pyproject_files}
%doc README.md
%license %{python3_sitelib}/aw_core-%{version}.dist-info/LICENSE.txt
%{_mandir}/man1/aw-cli.1*
%{_bindir}/aw-cli

%changelog
## START: Generated by rpmautospec
* Fri Dec 20 2024 Carl George <carlwgeorge@fedoraproject.org> - 0.5.17-1
- Update to version 0.5.17 rhbz#2333482
- Add missing click dependency
- Avoid duplicate LICENSE.txt file

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.16^20240507.3b83ab5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Tue Jul 09 2024 Carl George <carlwgeorge@fedoraproject.org> - 0.5.16^20240507.3b83ab5-3
- Remove platformdirs upper limit

* Sat Jun 08 2024 Python Maint <python-maint@redhat.com> - 0.5.16^20240507.3b83ab5-2
- Rebuilt for Python 3.13

* Sun Jun 02 2024 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> - 0.5.16^20240507.3b83ab5-1
- Initial import (fedora#2281000).
## END: Generated by rpmautospec