## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 5;
    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 xd
%global pypi_name xdfile
%global date 20240101
%global commit 3349ddcf5f4503b243ab9629d8cdbed756cbff56
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name:           python-%{pypi_name}
Version:        1.9.0~%{date}git%{shortcommit}
Release:        %autorelease
Summary:        Python parser for .xd crossword format

License:        MIT
URL:            https://github.com/century-arcade/xd
Source:         %{url}/archive/%{commit}/%{srcname}-%{commit}.tar.gz

BuildArch:      noarch
BuildRequires:  python3-devel
BuildRequires:  python3-pytest
BuildRequires:  sed

%global _description %{expand:
This package provides a simple parser for .xd -- a corpus-oriented format,
modeled after the simplicity and intuitiveness of the markdown format. It
supports 99.99% of published crosswords, and is intended to be convenient for
bulk analysis of crosswords by both humans and machines, from the present and
into the future.}

%description %_description

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

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

%prep
%autosetup -p1 -n %{srcname}-%{commit}

# remove bundled library
rm -r crossword

# remove unnecessary shebangs
sed -i 's:^#!/usr/bin/env python.*$::' xdfile/*.py

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files %{pypi_name}

# remove sample script
rm %{buildroot}%{_bindir}/sample

%check
# remove broken test
# https://github.com/century-arcade/xd/issues/72
rm xdfile/tests/test_xdfile.py
%pytest

%files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.md doc/xd-format.md

%changelog
## START: Generated by rpmautospec
* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.0~20240101git3349ddc-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sat Jun 08 2024 Python Maint <python-maint@redhat.com> - 1.9.0~20240101git3349ddc-4
- Rebuilt for Python 3.13

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.0~20240101git3349ddc-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.0~20240101git3349ddc-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Tue Jan 09 2024 Davide Cavalca <dcavalca@fedoraproject.org> - 1.9.0~20240101git3349ddc-1
- Initial import; Fixes: RHBZ#2138487
## END: Generated by rpmautospec