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