%if 0%{?fedora} || 0%{?rhel} >= 8
%global with_py3 1
%endif
%global srcname fastcache
Name: python-%{srcname}
Version: 1.0.2
Release: 9%{?dist}
Summary: C implementation of python3 lru_cache
License: MIT
URL: https://github.com/pbrady/%{srcname}
Source0: https://github.com/pbrady/%{srcname}/archive/v%{version}.tar.gz
BuildRequires: gcc
BuildRequires: python2-devel
BuildRequires: pycmd
BuildRequires: python2-pytest
BuildRequires: python2-setuptools
%if 0%{?with_py3}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-pycmd
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-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.
%package -n python2-%{srcname}
Summary: C implementation of python3 lru_cache
%{?python_provide:%python_provide python2-%{srcname}}
%description -n python2-%{srcname}
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 python%{python3_pkgversion}-%{srcname}
Summary: C implementation of python3 lru_cache
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}
%description -n python%{python3_pkgversion}-%{srcname}
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 -n %{srcname}-%{version}
%build
# Python 2 build
%py2_build "--define=WITH_THREAD"
%if 0%{?with_py3}
# Python 3 build
%py3_build "--define=WITH_THREAD"
%endif
%install
# Python 2 install
%py2_install
chmod 0755 %{buildroot}%{python2_sitearch}/%{srcname}/*.so
%if 0%{?with_py3}
# Python 3 install
%py3_install
chmod 0755 %{buildroot}%{python3_sitearch}/%{srcname}/*.so
%endif
%check
# Python 2 tests
export PYTHONPATH=%{buildroot}%{python2_sitearch}
mkdir -p empty
cd empty
%{__python2} << EOF
import fastcache
if not fastcache.test():
raise Exception('Tests failed')
EOF
cd -
%if 0%{?with_py3}
# Python 3 tests
export PYTHONPATH=%{buildroot}%{python3_sitearch}
rm -rf emtpy
mkdir -p empty
cd empty
%{__python3} << EOF
import fastcache
if not fastcache.test():
raise Exception('Tests failed')
EOF
cd -
%endif
%files -n python2-%{srcname}
%doc CHANGELOG README.md
%license LICENSE
%{python2_sitearch}/%{srcname}/
%{python2_sitearch}/%{srcname}*.egg-info/
%exclude %{python2_sitearch}/%{srcname}/tests
%if 0%{?with_py3}
%files -n python%{python3_pkgversion}-%{srcname}
%doc CHANGELOG README.md
%license LICENSE
%{python3_sitearch}/%{srcname}/
%{python3_sitearch}/%{srcname}*.egg-info/
%exclude %{python3_sitearch}/%{srcname}/tests
%endif
%changelog
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.2-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Thu Dec 22 2016 Orion Poplawski <orion@cora.nwra.com> - 1.0.2-8
- Build python3 for EPEL
- Use single build directory
- Run tests as upstream does
* Mon Dec 19 2016 Miro HronĨok <mhroncok@redhat.com> - 1.0.2-7
- Rebuild for Python 3.6
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.2-6
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Mon Feb 1 2016 Jerry James <loganjerry@gmail.com> - 1.0.2-4
- Comply with latest python packaging guidelines
* Tue Nov 10 2015 Orion Poplawski <orion@cora.nwra.com> - 1.0.2-4
- Use python2/3_version macros
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.2-4
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* 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