# Conditional for release and snapshot builds. Uncomment for release-builds.
#global rel_build 1
# Settings used for build from snapshots.
%{!?rel_build:%global commit 325e2798e7fac914d94ccfbbd96a244ab5494a24}
%{!?rel_build:%global commit_date 20161104}
%{!?rel_build:%global shortcommit %(c=%{commit};echo ${c:0:7})}
%{!?rel_build:%global gitver git%{commit_date}-%{shortcommit}}
%{!?rel_build:%global gitrel .git%{commit_date}.%{shortcommit}}
%{!?rel_build:%global gittar %{name}-%{version}-%{gitver}.tar.gz}
%{?rel_build: %global gittar %{name}-%{version}.tar.gz}
%if 0%{?fedora} || 0%{?rhel} >= 8
%bcond_without python3
%else # 0#{?fedora} || 0#{?rhel} >= 8
%bcond_with python3
%endif # 0#{?fedora} || 0#{?rhel} >= 8
%global common_desc \
The NGram class extends the Python 'set' class with efficient fuzzy \
search for members by means of an N-gram similarity measure. It \
also has static methods to compare a pair of strings. \
\
The N-grams are character based not word-based, and the class does \
not implement a language model, merely searching for members by \
string similarity.
%global common_sum Set-based subclass providing fuzzy search based on N-grams
%global pypi_name ngram
Name: python-%{pypi_name}
Version: 3.3.0
Release: 10%{?gitrel}%{?dist}
Summary: %{common_sum}
License: LGPLv3+
URL: https://github.com/gpoulter/%{name}
%if 0%{?rel_build}
Source0: %{url}/archive/%{version}.tar.gz#/%{gittar}
%else # 0%%{?rel_build}
Source0: %{url}/archive/%{commit}.tar.gz#/%{gittar}
%endif # 0%%{?rel_build}
BuildArch: noarch
BuildRequires: help2man
%description
%{common_desc}
%package doc
Summary: Documentation-files for %{name}
# On RHEL <= 6 we need sphinx-10-build from EPEL.
%if 0%{?fedora} || 0%{?rhel} >= 7
BuildRequires: python-sphinx
%else #0%{?fedora} || 0%{?rhel} >= 7
BuildRequires: python-sphinx10
%endif #0%{?fedora} || 0%{?rhel} >= 7
%description doc
This package contains the documentation-files for %{name}.
%package -n python2-%{pypi_name}
Summary: %{common_sum}
BuildRequires: python-nose
BuildRequires: python-setuptools
BuildRequires: python2-devel
%if (0%{?rhel} && 0%{?rhel} <= 6)
BuildRequires: python-argparse
Requires: python-argparse
%endif # (0%%{?rhel} && 0%%{?rhel} <= 6)
%{?python_provide:%python_provide python2-%{pypi_name}}
%description -n python2-%{pypi_name}
%{common_desc}
%if %{with python3}
%package -n python3-%{pypi_name}
Summary: %{common_sum}
BuildRequires: python3-devel
BuildRequires: python3-nose
BuildRequires: python3-setuptools
%{?python_provide:%python_provide python3-%{pypi_name}}
%description -n python3-%{pypi_name}
%{common_desc}
%endif # %%{with python3}
%prep
%if 0%{?rel_build}
%autosetup -p 1
%else # 0%%{?rel_build}
%autosetup -n %{name}-%{commit} -p 1
%endif # 0%%{?rel_build}
%{__rm} -rf *.egg*
# On RHEL <= 6 we need sphinx-10-build from EPEL.
%if (0%{?rhel} && 0%{?rhel} <= 6)
%{__sed} -i -e 's!sphinx-build$!%{_bindir}/sphinx-1.0-build!' \
docs/Makefile
%endif # (0%%{?rhel} && 0%%{?rhel} <= 6)
# Fix path to script in testsuite.
%{__sed} -i -e 's!csvjoin.py!scripts/&!g' tests/test_csvjoin.py
%build
%py2_build
%if %{with python3}
%py3_build
%endif # %%{with python3}
# Build the autodocs.
pushd docs
%make_build html
%{__rm} -f _build/html/.buildinfo
%{_bindir}/find _build/html -type f -print0 | \
%{_bindir}/xargs -0 %{__sed} -i -e 's!\r$!!'
popd
%install
%py2_install
# Fixup the hashbang in Python-scripts.
# Remove the file-ext from Python-scripts.
for _file in %{buildroot}/%{_bindir}/*.py ; do
_new="`/bin/echo ${_file} | %{__sed} -e 's!.py$!!'`"
%{__sed} -e '1s@^#!.*python$@#!%{__python2}@' \
< ${_file} > ${_new}
%{__chmod} 0755 ${_new}
/bin/touch -r ${_file} ${_new}
%{__rm} -f ${_file}
%if %{with python3}
%{__mv} -f ${_new} ${_new}-%{python2_version}
%else # %%{with python3}
/bin/ln -f ${_new} ${_new}-%{python2_version}
%endif # %%{with python3}
done
%if %{with python3}
%py3_install
# Fixup the hashbang in Python-scripts.
# Remove the file-ext from Python-scripts.
for _file in %{buildroot}/%{_bindir}/*.py ; do
_new="`/bin/echo ${_file} | %{__sed} -e 's!.py$!!'`"
%{__sed} -e '1s@^#!.*python$@#!%{__python3}@' \
< ${_file} > ${_new}
%{__chmod} 0755 ${_new}
/bin/touch -r ${_file} ${_new}
%{__rm} -f ${_file}
/bin/ln -f ${_new} ${_new}-%{python3_version}
done
%endif # %%{with python3}
%if 0%{?fedora} || 0%{?rhel} >= 7
# Create man-pages.
%{__mkdir} -p %{buildroot}%{_mandir}/man1
export PYTHONPATH="$(/bin/pwd)"
for _file in %{buildroot}%{_bindir}/* ; do
_of="$(/bin/basename ${_file}).1"
%{_bindir}/help2man --version-string='%{version}' -s 1 -N \
-o %{buildroot}%{_mandir}/man1/${_of} ${_file}
done
unset PYTHONPATH
%{_bindir}/find %{buildroot} -type f -name '*.pyc' -print -delete
%{_bindir}/find %{buildroot} -type f -name '*.pyo' -print -delete
%endif # 0%%{?fedora} || 0%%{?rhel} >= 7
%check
export PYTHONPATH="$(/bin/pwd)"
%{_bindir}/nosetests -v
%if %{with python3}
%{_bindir}/nosetests-%{python3_version} -v
%endif # %%{with python3}
unset PYTHONPATH
%files doc
%license COPYING*
%doc README docs/_build/html
%files -n python2-%{pypi_name}
%license COPYING*
%doc README
%if %{without python3}
%{_bindir}/csvjoin
%if 0%{?fedora} || 0%{?rhel} >= 7
%{_mandir}/man1/csvjoin.1*
%endif # 0%%{?fedora} || 0%%{?rhel} >= 7
%endif # %%{without python3}
%{_bindir}/csvjoin-%{python2_version}
%if 0%{?fedora} || 0%{?rhel} >= 7
%{_mandir}/man1/csvjoin-%{python2_version}.1*
%endif # 0%%{?fedora} || 0%%{?rhel} >= 7
%{python2_sitelib}/%{pypi_name}.py
%{python2_sitelib}/%{pypi_name}.py?
%{python2_sitelib}/%{pypi_name}-%{version}-py%{python2_version}.egg-info
%if %{with python3}
%files -n python3-%{pypi_name}
%license COPYING*
%doc README
%{_bindir}/csvjoin
%{_bindir}/csvjoin-%{python3_version}
%{_mandir}/man1/csvjoin.1*
%{_mandir}/man1/csvjoin-%{python3_version}.1*
%{python3_sitelib}/__pycache__/%{pypi_name}.cpython-%{python3_version_nodots}*.py?
%{python3_sitelib}/%{pypi_name}.py
%{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info
%endif # %%{with python3}
%changelog
* Sun Apr 09 2017 Björn Esser <besser82@fedoraproject.org> - 3.3.0-10.git20161104.325e279
- Updated to snapshot
- Provide main-binary in Python3-package (rhbz#1437181)
- Refactored spec to recent guidelines
- Add man-pages on Fedora and EPEL >= 7
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 3.3.0-8
- Rebuild for Python 3.6
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.3.0-7
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.3.0-5
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
- Add pycache-glob for Python >= 3.5
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.3.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Wed May 28 2014 Kalev Lember <kalevlember@gmail.com> - 3.3.0-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4
* Fri May 09 2014 Björn Esser <bjoern.esser@gmail.com> - 3.3.0-1
- initial rpm release (#1096188)