Blob Blame Raw
%global realname jellyfish
# Share doc between python-jellyfish and python3-jellyfish
%global _docdir_fmt %{name}

%if 0%{?fedora}
%bcond_without python3
%else
%bcond_with python3
%endif

Name:           python-%{realname}
Version:        0.5.0
Release:        2%{?dist}
Summary:        A python library for doing approximate and phonetic matching of strings

Group:          Development/Languages
License:        BSD
URL:            https://github.com/jamesturk/%{realname}
Source0:        https://github.com/jamesturk/%{realname}/archive/%{version}.tar.gz#/%{realname}-%{version}.tar.gz 
# We do not use the C binding so we just install everything in site_lib
Patch0:         fix-build.patch
BuildArch:      noarch
BuildRequires:  python2-devel
BuildRequires:  python-setuptools
%if %{with python3}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
%endif

%description
Jellyfish does approximate and phonetic string matching. It
includes the following string comparison algorithms:
Levenshtein Distance, Damerau-Levenshtein Distance, 
Jaro Distance, Jaro-Winkler Distance, Match Rating Approach
Comparison and Hamming Distance

And the following phonetic encodings:
American Soundex, Metaphone, NYSIIS (New York State Identification
and Intelligence System), Match Rating Codex

%if %{with python3}
%package -n python3-%{realname}
Summary:        A python library for doing approximate and phonetic matching of strings

%description -n python3-%{realname}
Jellyfish does approximate and phonetic string matching. It
includes the following string comparison algorithms:
Levenshtein Distance, Damerau-Levenshtein Distance, 
Jaro Distance, Jaro-Winkler Distance, Match Rating Approach
Comparison and Hamming Distance

And the following phonetic encodings:
American Soundex, Metaphone, NYSIIS (New York State Identification
and Intelligence System), Match Rating Codex
%endif

%prep
%setup -q -n %{realname}-%{version}
%patch0 -p1

%build
# No need to use py3dir and rebuild for python3 as the source is
# python 2 and 3 compatible and 2to3 is not used
%{__python2} setup.py build

%install
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}

%if %{with python3}
%{__python3} setup.py install --skip-build --root %{buildroot}
%endif

%check
# unicodecsv is missing in Fedora so tests will fail until that is fixed
# {__python} setup.py test

%files
%license LICENSE
%doc README.rst docs/comparison.rst docs/index.rst docs/phonetic.rst docs/stemming.rst

%{python2_sitelib}/%{realname}
%{python2_sitelib}/%{realname}-%{version}-*.egg-info

%if %{with python3}
%files -n python3-%{realname}
%license LICENSE
%doc README.rst docs/comparison.rst docs/index.rst docs/phonetic.rst docs/stemming.rst
%{python3_sitelib}/%{realname}
%{python3_sitelib}/%{realname}*.egg-info
%endif

%changelog
* Wed Jun 03 2015 Michele Baldessari <michele@acksyn.org> - 0.5.0-2
- Incorporate feedback from review (drop defattr macro, share doc subdir between packages,
  avoid py3dir as the source is python 2 and 3 compatible)

* Thu Apr 23 2015 Michele Baldessari <michele@acksyn.org> - 0.5.0-1
- Initial build