# Conditional for release and snapshot builds. Uncomment for release-builds. %global rel_build 1 # Failsafe backport of Python2-macros for RHEL <= 6 %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %{!?python_version: %global python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")} %{!?__python2: %global __python2 %{__python}} %{!?python2_sitelib: %global python2_sitelib %{python_sitelib}} %{!?python2_sitearch: %global python2_sitearch %{python_sitearch}} %{!?python2_version: %global python2_version %{python_version}} # Settings used for build from snapshots. %{!?rel_build:%global commit 282578b9ef65aa2ec72153d6eb1fcff5c273a42f} %{!?rel_build:%global commit_date 20121007} %{!?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} # Can we build a Py3-pkg? %if 0%{?fedora} || 0%{?rhel} >= 8 %global with_python3 1 %endif #0%{?fedora} || 0%{?rhel} >= 8 %global common_description \ 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 pypi_name ngram Name: python-%{pypi_name} Version: 3.3.0 Release: 1%{?gitrel}%{?dist} Summary: Set-based subclass providing fuzzy search based on N-grams License: LGPLv3+ URL: https://github.com/gpoulter/%{name} # Sources for release-builds. %{?rel_build:Source0: %{url}/archive/%{version}.tar.gz#/%{gittar}} # Sources for snapshot-builds. %{!?rel_build:Source0: %{url}/archive/%{commit}.tar.gz#/%{gittar}} BuildArch: noarch BuildRequires: python-nose BuildRequires: python2-devel %if 0%{?rhel} && 0%{?rhel} <= 6 BuildRequires: python-argparse Requires: python-argparse %endif #0%{?rhel} && 0%{?rhel} <= 6 %description %{common_description} %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}. %if 0%{?with_python3} %package -n python3-%{pypi_name} Summary: Set-based subclass providing fuzzy search based on N-grams BuildRequires: python3-devel BuildRequires: python3-nose %description -n python3-%{pypi_name} %{common_description} %endif #0%{?with_python3} %prep %setup -q%{!?rel_build:n %{name}-%{commit}} rm -rf *%{pypi_name}*.egg-info # 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 %if 0%{?with_python3} rm -rf %{py3dir} cp -a . %{py3dir} %endif #0%{?with_python3} %build %{__python2} setup.py build # Build the autodocs. pushd docs make %{?_smp_mflags} html rm -f _build/html/.buildinfo find _build/html -type f -print0 | xargs -0 sed -i -e 's!\r$!!' popd # Build the Python3-version. %if 0%{?with_python3} pushd %{py3dir} %{__python3} setup.py build popd %endif #0%{?with_python3} %install # Prefer the scripts in %%{_bindir} from Python2-pkg. %if 0%{?with_python3} pushd %{py3dir} %{__python3} setup.py install -O1 --skip-build --root %{buildroot} rm -f %{buildroot}%{_bindir}/* popd %endif #0%{?with_python3} %{__python2} setup.py install -O1 --skip-build --root %{buildroot} # Fixup the hashbang in Python-scripts. # Remove the file-ext from Python-scripts. for _file in %{buildroot}/%{_bindir}/* do _new="`echo ${_file} | sed -e 's!.py$!!'`" sed -e '1s@^#!.*python$@#!%{__python2}@' < ${_file} > ${_new} && \ chmod 0755 ${_new} && \ touch -r ${_file} ${_new} && \ rm -f ${_file} done %check export PYTHONPATH="`pwd`" nosetests -v %if 0%{?with_python3} pushd %{py3dir} export PYTHONPATH="`pwd`" nosetests-%{python3_version} -v popd %endif #0%{?with_python3} %files %doc COPYING* README %{_bindir}/csvjoin %{python2_sitelib}/%{pypi_name}.py* %{python2_sitelib}/%{pypi_name}-%{version}-py%{python2_version}.egg-info %files doc %doc COPYING* README docs/_build/html %if 0%{?with_python3} %files -n python3-%{pypi_name} %doc COPYING* README %{python3_sitelib}/__pycache__/%{pypi_name}.cpython-%(echo %{python3_version} | sed -e 's!\.!!g').py? %{python3_sitelib}/%{pypi_name}.py* %{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info %endif #0%{?with_python3} %changelog * Fri May 09 2014 Björn Esser - 3.3.0-1 - initial rpm release (#1096188)