Blob Blame History Raw
%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%endif

# For EPEL5 make a python26 package.
%if %{?rhel}%{!?rhel:0} == 5
%global altpython python26
%global __altpython %{_bindir}/python2.6
# Disable byte compiling. Do ourselves later.
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') 
%endif

%if %{?fedora}%{!?fedora:0} >= 13
%global altpython python3
%global __altpython %{_bindir}/python3
%endif 

%if %{?altpython:1}%{!?altpython:0}
%{!?altpydir: %global altpydir %{_builddir}/%{altpython}-%{name}-%{version}-%{release}}
%{!?altpython_sitelib: %global altpython_sitelib %(%{__altpython} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%endif 

%global srcname dirq

Name:           python-dirq
Version:        1.2.1
Release:        2%{?dist}
Summary:        Directory based queue

Group:          Development/Languages
License:        ASL 2.0
URL:            http://code.google.com/p/%{srcname}/
Source0:        http://dirq.googlecode.com/files/%{srcname}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildArch:      noarch
BuildRequires:  python2-devel

%if %{?altpython:1}%{!?altpython:0}
BuildRequires:  %{altpython}-devel
%endif #end of altpython.

%description
The goal of this module is to offer a simple queue system using the 
underlying file system for storage, security and to prevent race 
conditions via atomic operations.  It focuses on simplicity, 
robustness and the ability to scale.

The python module dirq is compatible with the Perl 
module Directory::Queue.

%if %{?altpython:1}%{!?altpython:0}
%package -n %{altpython}-dirq
Summary:        Directory based queue for %{altpython}
Group:          Development/Languages
%if %{?rhel}%{!?rhel:0} == 5
Requires: python(abi) = 2.6
%endif

%description -n %{altpython}-dirq
The goal of this module is to offer a simple queue system using the 
underlying file system for storage, security and to prevent race 
conditions via atomic operations.  It focuses on simplicity, 
robustness and the ability to scale.

The python module dirq is compatible with the Perl 
module Directory::Queue.
%endif #end of altpython.

%prep
%setup -q -n %{srcname}-%{version}
chmod 644 examples/dirq_simple.py \
          examples/dirqset_simple.py

%if %{?altpython:1}%{!?altpython:0}
rm -rf   %{altpydir}
cp -a .  %{altpydir}
find %{altpydir} -name '*.py' | xargs sed -i '1s|^#!/usr/bin/env python|#!%{_bindir}/%{altpython}|'
%endif #end of altpython.

find -name '*.py' | xargs sed -i '1s|^#!/usr/bin/env python|#!%{__python}|'

%build
%{__python} setup.py build

%if %{?altpython:1}%{!?altpython:0}
pushd %{altpydir}
%{__altpython} setup.py build
popd
%endif #end of altpython.

%install
rm -rf $RPM_BUILD_ROOT
%if %{?altpython:1}%{!?altpython:0}
pushd %{altpydir}
%{__altpython} setup.py install --skip-build --root $RPM_BUILD_ROOT
popd
%endif #end of altpython.

%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT

%check
%{__python} setup.py test
# And remove compiled documentation.
rm -f test/*.pyc

%if %{?altpython:1}%{!?altpython:0}
pushd %{altpydir}
%{__altpython} setup.py test
# And remove compiled documentation.
rm -f test/*.pyc
popd
%endif #end of altpython.

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc README.rst CHANGES examples test
%{python_sitelib}/%{srcname}/
%if 0%{?rhel} != 5
%{python_sitelib}/%{srcname}-%{version}-py?.?.egg-info
%endif

%if %{?altpython:1}%{!?altpython:0}
%files -n %{altpython}-dirq
%defattr(-,root,root,-)
%doc README.rst CHANGES examples test
%{altpython_sitelib}/%{srcname}/
%{altpython_sitelib}/%{srcname}-%{version}-py?.?.egg-info
%endif #end of altpython.

%changelog
* Wed May 09 2012 Massimo Paladin <massimo.paladin@gmail.com> - 1.2.1-2
- Cleaning specfile and dependency error fixed on rhel5.

* Mon May 07 2012 Massimo Paladin <massimo.paladin@gmail.com> - 1.2.1-1
- Update to 1.2.1.

* Fri Mar 30 2012 Massimo Paladin <massimo.paladin@gmail.com> - 1.1.2-1
- Update to 1.1.2.

* Sat Jul 24 2010 Steve Traylen <steve.traylen@cern.ch> - 0.0.5-3 1
- Fix requires abi for python26 sub package.

* Wed Jul 21 2010 Steve Traylen <steve.traylen@cern.ch> - 0.0.5-3
- Really disable python3 support.
- Change /usr/bin/env python to /usr/bin/python everywhere.

* Tue Jun 29 2010 Steve Traylen <steve.traylen@cern.ch> - 0.0.5-2
- Disable python3 support and add link to bug.

* Mon Jun 28 2010 Steve Traylen <steve.traylen@cern.ch> - 0.0.5-1
- Initial packaging.