%if 0%{?fedora} || 0%{?rhel} >= 8
%global with_py3 1
%endif
%global pkgname fastcache
Name: python-%{pkgname}
Version: 1.0.2
Release: 2%{?dist}
Summary: C implementation of python3 lru_cache
License: MIT
URL: https://github.com/pbrady/%{pkgname}
Source0: https://github.com/pbrady/%{pkgname}/archive/v%{version}.tar.gz
BuildRequires: pycmd
BuildRequires: pytest
BuildRequires: python2-devel
BuildRequires: python-setuptools
%if 0%{?with_py3}
BuildRequires: python3-pycmd
BuildRequires: python3-pytest
BuildRequires: python3-devel
BuildRequires: python3-setuptools
%endif
%description
This package contains a C implementation of the python 3 lru_cache. It
passes all tests in the standard library for functools.lru_cache.
%if 0%{?with_py3}
%package -n python3-%{pkgname}
Summary: C implementation of python3 lru_cache
%description -n python3-%{pkgname}
This package contains a C implementation of the python 3 lru_cache. It
passes all tests in the standard library for functools.lru_cache.
%endif
%prep
%setup -q -c
%if 0%{?with_py3}
# Prepare for a python3 build
cp -a %{pkgname}-%{version} python3-%{pkgname}-%{version}
%endif
%build
# Python 2 build
pushd %{pkgname}-%{version}
%{__python2} setup.py build --define=WITH_THREAD
popd
%if 0%{?with_py3}
# Python 3 build
pushd python3-%{pkgname}-%{version}
%{__python3} setup.py build --define=WITH_THREAD
popd
%endif
%install
# Python 2 install
pushd %{pkgname}-%{version}
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}
chmod 0755 %{buildroot}%{python2_sitearch}/%{pkgname}/*.so
popd
%if 0%{?with_py3}
# Python 3 install
pushd python3-%{pkgname}-%{version}
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
chmod 0755 %{buildroot}%{python3_sitearch}/%{pkgname}/*.so
popd
%endif
%check
# Python 2 tests
pushd %{pkgname}-%{version}
py.cleanup-2.7 -p
export PYTHONPATH=build/lib.linux-%{_arch}-2.7/fastcache/tests
py.test-2.7 -v --ignore=fastcache/tests
popd
%if 0%{?with_py3}
# Python 3 tests
pushd python3-%{pkgname}-%{version}
py.cleanup-3.4 -p
export PYTHONPATH=build/lib.linux-%{_arch}-3.4/fastcache/tests
py.test-3.4 -v --ignore=fastcache/tests
popd
%endif
%files
%doc %{pkgname}-%{version}/CHANGELOG %{pkgname}-%{version}/README.md
%license %{pkgname}-%{version}/LICENSE
%{python2_sitearch}/%{pkgname}/
%{python2_sitearch}/%{pkgname}*.egg-info/
%exclude %{python2_sitearch}/%{pkgname}/tests
%if 0%{?with_py3}
%files -n python3-%{pkgname}
%doc %{pkgname}-%{version}/CHANGELOG %{pkgname}-%{version}/README.md
%license %{pkgname}-%{version}/LICENSE
%{python3_sitearch}/%{pkgname}/
%{python3_sitearch}/%{pkgname}*.egg-info/
%exclude %{python3_sitearch}/%{pkgname}/tests
%endif
%changelog
* Mon Dec 1 2014 Jerry James <loganjerry@gmail.com> - 1.0.2-2
- Be more verbose in the file listing
- Run the tests verbosely
* Fri Nov 21 2014 Jerry James <loganjerry@gmail.com> - 1.0.2-1
- Initial RPM