From 32706eaef39be8df3bbb462f72c31311adc0f92d4fe73a865d2e46837a2fa56e Mon Sep 17 00:00:00 2001
From: Denisart Benjamin
Date: Fri, 11 Oct 2013 17:08:38 +0000
Subject: [PATCH] Accepting request 203001 from
home:posophe:branches:devel:languages:python
update-alternative implementation
OBS-URL: https://build.opensuse.org/request/show/203001
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Cython?expand=0&rev=33
---
python-Cython.changes | 5 +++++
python-Cython.spec | 31 +++++++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/python-Cython.changes b/python-Cython.changes
index 78ef3d7..88bc48c 100644
--- a/python-Cython.changes
+++ b/python-Cython.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Fri Oct 11 17:06:20 UTC 2013 - p.drouand@gmail.com
+
+- Implement update-alternatives
+
-------------------------------------------------------------------
Mon May 13 08:17:40 UTC 2013 - dmueller@suse.com
diff --git a/python-Cython.spec b/python-Cython.spec
index f64911c..35a06fb 100644
--- a/python-Cython.spec
+++ b/python-Cython.spec
@@ -29,6 +29,8 @@ BuildRequires: fdupes
BuildRequires: python-devel
Provides: python-cython = %{version}
Obsoletes: python-cython < %{version}
+Requires(post): update-alternatives
+Requires(postun): update-alternatives
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%endif
@@ -52,14 +54,37 @@ code.
%setup -q -n Cython-%{version}
sed -i "s|^#!.*||" Cython/Debugger/{libpython,Cygdb}.py cython.py # Fix non-executable scripts
sed -i "s|\r||" Demos/callback/{README.txt,cheesefinder.h} Demos/embed/Makefile.{unix,msc.static} Doc/primes.c # Fix EOL encoding
+mv bin/cython bin/cython-%{py_ver}
+mv bin/cygdb bin/cygdb-%{py_ver}
+sed -i "s|bin/cython|bin/cython-%{py_ver}|" setup.py
+sed -i "s|bin/cygdb|bin/cygdb-%{py_ver}|" setup.py
%build
CFLAGS="%{optflags}" python setup.py build
%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
+ln -s %{_bindir}/cython-%{py_ver} %{buildroot}%{_bindir}/cython
+ln -s %{_bindir}/cygdb-%{py_ver} %{buildroot}%{_bindir}/cygdb
%fdupes -s %{buildroot}%{python_sitearch} %{buildroot}%{_docdir}
+%pre
+# Since /usr/bin/cython and /usr/bin/cygdb became ghosted to be used with update-alternatives, we have to get rid
+# of the old binary resulting from the non-update-alternativies-ified package:
+[[ ! -L %{_bindir}/cygdb ]] && rm -f %{_bindir}/cygdb
+[[ ! -L %{_bindir}/cython ]] && rm -f %{_bindir}/cython
+exit 0
+
+%post
+update-alternatives \
+ --install %{_bindir}/cython cython %{_bindir}/cython-%{py_ver} 30 \
+ --slave %{_bindir}/cygdb cygdb %{_bindir}/cygdb-%{py_ver}
+
+%preun
+if [ $1 -eq 0 ] ; then
+ update-alternatives --remove cython %{_bindir}/cython-%{py_ver}
+fi
+
# Disabled testsuite as it takes a long time:
#%%check
#python runtests.py
@@ -67,8 +92,10 @@ python setup.py install --prefix=%{_prefix} --root=%{buildroot}
%files
%defattr(-,root,root,-)
%doc COPYING.txt LICENSE.txt README.txt ToDo.txt USAGE.txt Doc Demos
-%{_bindir}/cygdb
-%{_bindir}/cython
+%ghost %{_bindir}/cygdb
+%{_bindir}/cygdb-%{py_ver}
+%ghost %{_bindir}/cython
+%{_bindir}/cython-%{py_ver}
%{python_sitearch}/Cython/
%{python_sitearch}/Cython-%{version}-py%{py_ver}.egg-info
%{python_sitearch}/cython.py*