%bcond_without tests
Name: python-editdistance
Version: 0.6.0
Release: %autorelease
Summary: Fast implementation of the edit distance (Levenshtein distance)
License: MIT
URL: https://github.com/aflc/editdistance
Source0: %{url}/archive/v%{version}/editdistance-%{version}.tar.gz
BuildRequires: python3-devel
BuildRequires: gcc-c++
BuildRequires: %{py3_dist setuptools}
BuildRequires: %{py3_dist Cython}
%if %{with tests}
BuildRequires: %{py3_dist pytest}
%endif
%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}
rm -rf editdistance.egg-info
# 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
%build
# Cythonize editdistance/bycython.pyx manually; setup.py does not handle it.
find . -type f -name '*.pyx' | xargs -r cythonize --inplace
%py3_build
%install
%py3_install
%check
%if %{with tests}
PYTHONPATH=%{buildroot}%{python3_sitearch} %pytest
%endif
%files -n python3-editdistance
%doc README.rst
%license LICENSE
# own the installation directory
%dir %{python3_sitearch}/editdistance
%{python3_sitearch}/editdistance/__init__.py
# own the __pycache__ directory
%dir %{python3_sitearch}/editdistance/__pycache__/
%{python3_sitearch}/editdistance/__pycache__/*
%{python3_sitearch}/editdistance/bycython.cpython-*.so
%{python3_sitearch}/editdistance-%{version}-py%{python3_version}.egg-info
%exclude %{python3_sitearch}/editdistance/*.h
%changelog
%autochangelog