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

%global srcname simplevisor

Name:		python-simplevisor
Version:	0.7
Release:	1%{?dist}
Summary:	Python simple daemons supervisor

Group:		Development/Libraries
License:	ASL 2.0
URL:		https://github.com/cern-mig/%{name}
Source0:	http://pypi.python.org/packages/source/s/%{srcname}/%{srcname}-%{version}.tar.gz
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildArch:	noarch
BuildRequires:	python2-devel
Requires:	perl-Config-General
Requires:	perl-No-Worries
%if 0%{?with_python3}
BuildRequires:	python3-devel
%endif # if with_python3
%if ! 0%{?with_python3}
BuildRequires:	python-argparse
Requires:	python-argparse
%endif
# For python < 2.6 python-siplejson is required
%if 0%{?fedora} < 11 || 0%{?rhel} <= 6
BuildRequires:	python-simplejson
Requires:	python-simplejson
%endif

%description
Simplevisor is a simple daemons supervisor, it is inspired by
Erlang OTP and it can supervise hierarchies of services.

%if 0%{?with_python3}
%package -n python3-simplevisor
Summary:	Python simple daemons supervisor
Group:		Development/Libraries

%description -n python3-simplevisor
Simplevisor is a simple daemons supervisor, it is inspired by
Erlang OTP and it can supervise hierarchies of services.
%endif # with_python3

%prep
%setup -q -n %{srcname}-%{version}

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif # with_python3

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

%build 
%{__python} setup.py build

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

%install
rm -rf $RPM_BUILD_ROOT

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root $RPM_BUILD_ROOT
mv $RPM_BUILD_ROOT/usr/bin/simplevisor $RPM_BUILD_ROOT/usr/bin/simplevisor3
mv $RPM_BUILD_ROOT/usr/bin/simplevisor-control $RPM_BUILD_ROOT/usr/bin/simplevisor3-control
sed -i 's|/usr/bin/python|/usr/bin/python3|' $RPM_BUILD_ROOT/usr/bin/simplevisor3-control
install -D -m 644 man/%{srcname}.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}3.1;
install -D -m 644 man/%{srcname}-control.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}3-control.1;
install -D -m 644 man/%{srcname}-loop.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}-loop.1;
popd
%endif # with_python3

%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT
install -D -m 644 man/%{srcname}.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}.1;
install -D -m 644 man/%{srcname}-control.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}-control.1;
install -D -m 644 man/%{srcname}-loop.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}-loop.1;

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

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py test
rm -f test/*.pyc
popd
%endif # with_python3

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc LICENSE README.rst CHANGES examples
%{_mandir}/man?/%{srcname}.1*
%{_mandir}/man?/%{srcname}-control.1*
%{_mandir}/man?/%{srcname}-loop.1*
%attr(755, root, root) /usr/bin/simplevisor
%attr(755, root, root) /usr/bin/simplevisor-control
%attr(755, root, root) /usr/bin/simplevisor-loop
%{python_sitelib}/%{srcname}/
%if 0%{?rhel} != 5
%{python_sitelib}/%{srcname}-%{version}-py?.?.egg-info
%endif

%if 0%{?with_python3}
%files -n python3-simplevisor
%doc LICENSE README.rst CHANGES
%{_mandir}/man?/%{srcname}3.1*
%{_mandir}/man?/%{srcname}3-control.1*
%{_mandir}/man?/%{srcname}-loop.1*
%attr(755, root, root) /usr/bin/simplevisor3
%attr(755, root, root) /usr/bin/simplevisor3-control
%attr(755, root, root) /usr/bin/simplevisor-loop
%{python3_sitelib}/%{srcname}-%{version}-py?.?.egg-info
%{python3_sitelib}/%{srcname}/
%endif # with_python3

%changelog
* Mon Jan 28 2013 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.7-1
- Updating to upstream 0.7.

* Thu Jan 17 2013 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.6-1
- Updating to upstream 0.6.

* Fri Nov 30 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.5-2
- Use macros consistently.

* Fri Sep 14 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.5-1
- Updating to version 0.5.

* Thu Jul 05 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.4-1
- Updating to version 0.4.

* Mon Jun 25 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.3-1
- Updating to version 0.3.

* Mon Mar 14 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.2-1
- Improvements.

* Mon Mar 11 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.1-1
- Initial packaging.