0e259d2
%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
0e259d2
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
0e259d2
%endif
0e259d2
0e259d2
# For EPEL5 make a python26 package.
0e259d2
%if %{?rhel}%{!?rhel:0} == 5
0e259d2
%global altpython python26
0e259d2
%global __altpython %{_bindir}/python2.6
0e259d2
# Disable byte compiling. Do ourselves later.
0e259d2
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') 
0e259d2
%endif
0e259d2
0e259d2
# python3 support not possible at the moment.
0e259d2
# http://code.google.com/p/dirq/issues/detail?id=1
0e259d2
#%%if %%{?fedora}%%{!?fedora:0} >= 13
0e259d2
#%%global altpython python3
0e259d2
#%%global __altpython %%{_bindir}/python3
0e259d2
#%%endif 
0e259d2
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
%{!?altpydir: %global altpydir %{_builddir}/%{altpython}-%{name}-%{version}-%{release}}
0e259d2
%{!?altpython_sitelib: %global altpython_sitelib %(%{__altpython} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
0e259d2
%endif 
0e259d2
0e259d2
Name:           python-dirq
0e259d2
Version:        0.0.5
0e259d2
Release:        3%{?dist}
0e259d2
Summary:        Directory based queue
0e259d2
0e259d2
Group:          Development/Languages
0e259d2
License:        ASL 2.0
0e259d2
URL:            http://code.google.com/p/dirq/
0e259d2
Source0:        http://dirq.googlecode.com/files/dirq-0.0.5.tar.gz
0e259d2
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
0e259d2
0e259d2
BuildArch:      noarch
0e259d2
BuildRequires:  python-devel
0e259d2
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
%if %{?rhel}%{!?rhel:0} == 5
0e259d2
Requires: python(abi) = 2.6
0e259d2
%endif
0e259d2
# Required for 2to3
0e259d2
%if %{?fedora}%{!?fedora:0} >= 13
0e259d2
BuildRequires:  python-tools
0e259d2
%endif
0e259d2
BuildRequires:  %{altpython}-devel
0e259d2
%endif #end of altpython.
0e259d2
0e259d2
%description
0e259d2
The goal of this module is to offer a simple queue system using the 
0e259d2
underlying file system for storage, security and to prevent race 
0e259d2
conditions via atomic operations.  It focuses on simplicity, 
0e259d2
robustness and the ability to scale.
0e259d2
0e259d2
The python module dirq is compatible with the Perl 
0e259d2
module Directory::Queue.
0e259d2
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
%package -n %{altpython}-dirq
0e259d2
Summary:        Directory based queue for %{altpython}
0e259d2
Group:          Development/Languages
0e259d2
0e259d2
%description -n %{altpython}-dirq
0e259d2
The goal of this module is to offer a simple queue system using the 
0e259d2
underlying file system for storage, security and to prevent race 
0e259d2
conditions via atomic operations.  It focuses on simplicity, 
0e259d2
robustness and the ability to scale.
0e259d2
0e259d2
The python module dirq is compatible with the perl 
0e259d2
module Directory::Queue.
0e259d2
%endif #end of altpython.
0e259d2
0e259d2
%prep
0e259d2
%setup -q -n dirq-%{version}
0e259d2
chmod 644 examples/dirq_simple.py \
0e259d2
          examples/dirqset_simple.py
0e259d2
sed -i '1s|#!%{_bindir}/env python|#!%{_bindir}/python|' \
0e259d2
           examples/dirqset_simple.py \
0e259d2
           examples/dirq_simple.py \
0e259d2
           test/test_dirq.py
0e259d2
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
rm -rf   %{altpydir}
0e259d2
mkdir -p %{altpydir}
0e259d2
cp -a *  %{altpydir}
0e259d2
pushd %{altpydir}
0e259d2
%if %{?fedora}%{!?fedora:0} >= 13
0e259d2
2to3 --write --nobackups .
0e259d2
%endif
0e259d2
sed -i '1s|#!%{_bindir}/python|#!%{_bindir}/%{altpython}|' \
0e259d2
           examples/dirqset_simple.py \
0e259d2
           examples/dirq_simple.py \
0e259d2
           test/test_dirq.py
0e259d2
popd
0e259d2
%endif
0e259d2
0e259d2
%build
0e259d2
%{__python} setup.py build
0e259d2
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
pushd %{altpydir}
0e259d2
%{__altpython} setup.py build
0e259d2
popd
0e259d2
%endif
0e259d2
0e259d2
0e259d2
%install
0e259d2
rm -rf $RPM_BUILD_ROOT
0e259d2
%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT
0e259d2
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
pushd %{altpydir}
0e259d2
%{__altpython} setup.py install --skip-build --root $RPM_BUILD_ROOT
0e259d2
popd
0e259d2
%endif
0e259d2
0e259d2
%if %{?fedora}%{!?fedora:0} < 5 && %{?rhel}%{!?rhel:0} < 6
0e259d2
%{__python} -c 'import compileall; compileall.compile_dir("'"$RPM_BUILD_ROOT"'", 10, "%{python_sitearch}", 1)' > /dev/null
0e259d2
%{__python} -O -c 'import compileall; compileall.compile_dir("'"$RPM_BUILD_ROOT"'", 10, "%{python_sitearch}", 1)' > /dev/null
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
%{__altpython} -c 'import compileall; compileall.compile_dir("'"$RPM_BUILD_ROOT%{altpython_sitearch}"'", 10, "%{altpython_sitearch}", 1)' > /dev/null
0e259d2
%{__altpython} -O -c 'import compileall; compileall.compile_dir("'"$RPM_BUILD_ROOT%{altpython_sitearch}"'", 10, "%{altpython_sitearch}", 1)' > /dev/null
0e259d2
%endif
0e259d2
%endif 
0e259d2
0e259d2
0e259d2
%check
0e259d2
%{__python} setup.py test
0e259d2
# And remove compiled documentation.
0e259d2
rm -f test/*.pyc
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
pushd %{altpydir}
0e259d2
%{__altpython} setup.py test
0e259d2
# And remove compiled documentation.
0e259d2
rm -f test/*.pyc
0e259d2
popd
0e259d2
%endif
0e259d2
0e259d2
%clean
0e259d2
rm -rf $RPM_BUILD_ROOT
0e259d2
0e259d2
%files
0e259d2
%defattr(-,root,root,-)
0e259d2
%doc README CHANGES examples test
0e259d2
%{python_sitelib}/*
0e259d2
0e259d2
%if %{?altpython:1}%{!?altpython:0}
0e259d2
%files -n %{altpython}-dirq
0e259d2
%defattr(-,root,root,-)
0e259d2
%doc README CHANGES examples test
0e259d2
%{altpython_sitelib}/*
0e259d2
%endif
0e259d2
0e259d2
%changelog
0e259d2
* Wed Jul 31 2010 Steve Traylen <steve.traylen@cern.ch> - 0.0.5-3
0e259d2
- Really disable python3 support.
0e259d2
- Change /usr/bin/env python to /usr/bin/python everywhere.
0e259d2
0e259d2
* Tue Jun 29 2010 Steve Traylen <steve.traylen@cern.ch> - 0.0.5-2
0e259d2
- Disable python3 support and add link to bug.
0e259d2
0e259d2
* Mon Jun 28 2010 Steve Traylen <steve.traylen@cern.ch> - 0.0.5-1
0e259d2
- Initial packaging.
0e259d2