## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## 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

Name:           python-editdistance
Version:        0.8.1
Release:        %autorelease
Summary:        Fast implementation of the edit distance (Levenshtein distance)

# SPDX
License:        MIT
URL:            https://github.com/roy-ht/editdistance
# The PyPI sdist lacks tests, so we use the GitHub archive.
Source:         %{url}/archive/v%{version}/editdistance-%{version}.tar.gz

BuildRequires:  python3-devel
BuildRequires:  gcc-c++

BuildRequires:  %{py3_dist pytest}

%global _description %{expand:
Fast implementation of the edit distance (Levenshtein distance).

This library simply implements Levenshtein distance with C++ and Cython.

The algorithm used in this library is proposed by Heikki Hyyrö,
"Explaining and extending the bit-parallel approximate string matching
algorithm of Myers", (2001).}

%description %{_description}


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

%description -n python3-editdistance %{_description}


%prep
%autosetup -n editdistance-%{version}

# Remove files generated by Cython to regenerate them; note that
# editdistance/_editdistance.cpp is not generated code.
grep -rl '/\* Generated by Cython' | xargs -r rm -v


%generate_buildrequires
%pyproject_buildrequires


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files -L editdistance

# 0.8.1: pep517 based build packages some files which should not be packaged
# and compile time warnings
# https://github.com/roy-ht/editdistance/issues/112
# “I couldn’t find any documentation on how to control this with the PDM build
# backend, so I worked around it downstream rather than offering a PR to fix it
# properly.”
find %{buildroot}%{python3_sitearch} -type f \( \
    -name '.git*' -o -name '*.cpp' -o -name '*.h' \
    \) -print -delete
sed -r -i '/\.(cpp|h)/d' %{pyproject_files}


%check
%pytest


%files -n python3-editdistance -f %{pyproject_files}
%license LICENSE
%doc README.md


%changelog
## START: Generated by rpmautospec
* Sun Feb 11 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.8.1-1
- Update to 0.8.1 (close RHBZ#2263735)

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Tue Jan 02 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.6.2-4
- Assert that the .dist-info directory contains a license file

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Tue Jun 13 2023 Python Maint <python-maint@redhat.com> - 0.6.2-2
- Rebuilt for Python 3.12

* Wed Apr 19 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.6.2-1
- Update to 0.6.2 (close RHBZ#2138604)

* Wed Apr 19 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.6.0-10
- Port to pyproject-rpm-macros

* Wed Apr 19 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.6.0-9
- Stop conditionalizing the tests

* Wed Apr 19 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.6.0-8
- Confirm License is SPDX MIT

* Wed Apr 19 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.6.0-7
- Tidy up packaging a bit

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 0.6.0-3
- Rebuilt for Python 3.11

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Sun Oct 24 2021 Aniket Pradhan <major AT fedoraproject DOT org> - 0.6.0-1
- Update to v0.6.0

* Tue Jul 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.3-8
- Second attempt - Rebuilt for
  https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.5.3-7
- Rebuilt for Python 3.10

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.3-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Thu Jun 25 2020 Aniket Pradhan <major AT fedoraproject DOT org> - 0.5.3-4
- Added setuptools to BuildRequires

* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.5.3-3
- Rebuilt for Python 3.9

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

* Fri Nov 8 2019 Aniket Pradhan <major AT fedoraproject DOT org> - 0.5.3-1
- Initial build

## END: Generated by rpmautospec