Blob Blame History Raw
# RHEL 6 compatibility.
%if 0%{?fedora} > 12
%global with_python3 1
%else
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
%endif

%global projectname cached-property
%global modulename cached_property
%global commit 2990020888089841314ad9dd4b0aa6f4d63c4d25 
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name:           python-%{modulename}
Version:        1.0.0 
Release:        3%{?dist}
Summary:        A cached-property for decorating methods in Python classes
License:        BSD
URL:            https://github.com/pydanny/%{projectname}
Source0:        https://github.com/pydanny/%{projectname}/archive/%{commit}/%{projectname}-%{commit}.tar.gz

BuildArch:      noarch
Provides:       python2-%{modulename}
BuildRequires:  python2-devel
BuildRequires:  python-tox
BuildRequires:  python-freezegun

%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-freezegun
%endif # with_python3

%description
cached_property allows properties in Python classes to be cached until the cache
is invalidated or expired.

%if 0%{?with_python3}
%package -n python3-%{projectname}
Summary:        A cached-property for decorating methods in Python classes.

%description -n python3-%{projectname}
cached_property allows properties in Python classes to be cached until the cache
is invalidated or expired.
%endif # with_python3

%prep
%setup -q -n %{projectname}-%{commit}

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif # with_python3

%build
%{__python2} setup.py build

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif # with_python3

%install
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
popd
%endif # with_python3

%check
# --skip-missing-interpreters only exists in tox >= 1.7.2.
# --sitepackages only exists in tox >= 1.7.0.
# Fedora 20 and 21 have 1.7.1, RHEL 6 and 7 have 1.4.2.
# I'm gonna go ahead and guess RHEL 8 will have something new enough...
%if 0%{?fedora} > 21 || 0%{?rhel} > 7
tox --sitepackages --skip-missing-interpreters
%endif

%files
%{!?_licensedir:%global license %%doc}
%doc AUTHORS.rst HISTORY.rst CONTRIBUTING.rst README.rst
%license LICENSE
%{python2_sitelib}/%{modulename}*

%if 0%{?with_python3}
%files -n python3-%{projectname}
%doc AUTHORS.rst HISTORY.rst CONTRIBUTING.rst README.rst
%license LICENSE
%{python3_sitelib}/%{modulename}*
%{python3_sitelib}/__pycache__/%{modulename}*
%endif # with_python3

%changelog
* Wed Mar 25 2015 Adam Williamson <awilliam@redhat.com> - 1.0.0-3
- python3 build only for Fedora (no python3 in RHEL6 or 7)
- provide python2-cached_property
- guard against %license not being available
- only run tests on F>=22 (tox is too old on everything else)

* Fri Mar 13 2015 Pete Travis <me@petetravis.com> - 1.0.0-2
- Use the module name for the package name.

* Fri Feb 20 2015 Pete Travis <me@petetravis.com> 1.0.0-1
- Initial packaging.