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

# python3 support not possible at the moment.
# http://code.google.com/p/dirq/issues/detail?id=1
%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 

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

Group:          Development/Languages
License:        ASL 2.0
URL:            http://code.google.com/p/dirq/
Source0:        http://dirq.googlecode.com/files/dirq-%{version}.tar.gz
# http://code.google.com/p/dirq/issues/detail?id=1#c1
Patch0:         dirq-1.0.1-dist-tag.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildArch:      noarch
BuildRequires:  python-devel

%if %{?altpython:1}%{!?altpython:0}
%if %{?rhel}%{!?rhel:0} == 5
Requires: python(abi) = 2.6
%endif
# Required for 2to3
%if %{?fedora}%{!?fedora:0} >= 13
BuildRequires:  python-tools
%endif
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

%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 dirq-%{version}
%patch0 -p1
chmod 644 examples/dirq_simple.py \
          examples/dirqset_simple.py
sed -i '1s|#!%{_bindir}/env python|#!%{_bindir}/python|' \
           examples/dirqset_simple.py \
           examples/dirq_simple.py \
           test/test_dirq.py

%if %{?altpython:1}%{!?altpython:0}
rm -rf   %{altpydir}
mkdir -p %{altpydir}
cp -a *  %{altpydir}
pushd %{altpydir}
%if %{?fedora}%{!?fedora:0} >= 13
2to3 --write --nobackups .
%endif
sed -i '1s|#!%{_bindir}/python|#!%{_bindir}/%{altpython}|' \
           examples/dirqset_simple.py \
           examples/dirq_simple.py \
           test/test_dirq.py
popd
%endif

%build
%{__python} setup.py build

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


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

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

%if %{?fedora}%{!?fedora:0} < 5 && %{?rhel}%{!?rhel:0} < 6
%{__python} -c 'import compileall; compileall.compile_dir("'"$RPM_BUILD_ROOT"'", 10, "%{python_sitearch}", 1)' > /dev/null
%{__python} -O -c 'import compileall; compileall.compile_dir("'"$RPM_BUILD_ROOT"'", 10, "%{python_sitearch}", 1)' > /dev/null
%if %{?altpython:1}%{!?altpython:0}
%{__altpython} -c 'import compileall; compileall.compile_dir("'"$RPM_BUILD_ROOT%{altpython_sitearch}"'", 10, "%{altpython_sitearch}", 1)' > /dev/null
%{__altpython} -O -c 'import compileall; compileall.compile_dir("'"$RPM_BUILD_ROOT%{altpython_sitearch}"'", 10, "%{altpython_sitearch}", 1)' > /dev/null
%endif
%endif 


%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

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc README CHANGES examples test
%{python_sitelib}/*

%if %{?altpython:1}%{!?altpython:0}
%files -n %{altpython}-dirq
%defattr(-,root,root,-)
%doc README CHANGES examples test
%{altpython_sitelib}/*
%endif

%changelog
* Tue Feb 14 2012 Steve Traylen <steve.traylen@cern.ch> - 1.0.1-1
- Update to 1.0.1.
- Enable python3 support with patch dirq-1.0.1-dist-tag.patch.

* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0.5-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0.5-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Sat Jul 31 2010 Thomas Spura <tomspur@fedoraproject.org> - 0.0.5-4
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Wed Jul 31 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.