Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} >= 8
%global with_py3 1
%endif

%global pkgname fastcache

Name:           python-%{pkgname}
Version:        1.0.2
Release:        4%{?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-%{python2_version} -p
export PYTHONPATH=build/lib.linux-%{_arch}-%{python2_version}/fastcache/tests
py.test-%{python2_version} -v --ignore=fastcache/tests
popd

%if 0%{?with_py3}
# Python 3 tests
pushd python3-%{pkgname}-%{version}
py.cleanup-%{python3_version} -p
export PYTHONPATH=build/lib.linux-%{_arch}-%{python3_version}/fastcache/tests
py.test-%{python3_version} -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
* 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