[packages/python-Cython] - build both python2/python3 modules from single spec

qboosh qboosh at pld-linux.org
Sun Feb 16 14:07:31 CET 2014


commit 50da01819b5b05098052463ad8cb13601de5caa2
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sun Feb 16 14:09:29 2014 +0100

    - build both python2/python3 modules from single spec

 python-Cython.spec | 101 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 90 insertions(+), 11 deletions(-)
---
diff --git a/python-Cython.spec b/python-Cython.spec
index 528a0e3..c3a7f02 100644
--- a/python-Cython.spec
+++ b/python-Cython.spec
@@ -1,8 +1,12 @@
+#
+# Conditional build:
+%bcond_without	python2		# CPython 2.x module
+%bcond_without	python3		# CPython 3.x module
 
 %define		module	Cython
 
-Summary:	Language for writing Python Extension Modules
-Summary(pl.UTF-8):	Język służący do pisania modułów rozszerzających Pythona
+Summary:	Language for writing Python Extension Modules (Python 2.x version)
+Summary(pl.UTF-8):	Język służący do pisania modułów rozszerzających Pythona (wersja dla Pythona 2.x)
 Name:		python-%{module}
 Version:	0.20.1
 Release:	1
@@ -11,11 +15,19 @@ Group:		Libraries/Python
 Source0:	http://www.cython.org/release/%{module}-%{version}.tar.gz
 # Source0-md5:	52431696c64e618036537c4d9aa79d99
 URL:		http://www.cython.org/
+%if %{with python2}
 BuildRequires:	python >= 1:2.5
 BuildRequires:	python-devel
+%endif
+%if %{with python3}
+BuildRequires:	python3
+BuildRequires:	python3-2to3
+BuildRequires:	python3-devel
+BuildRequires:	python3-distribute
+BuildRequires:	python3-modules
+%endif
 BuildRequires:	rpm-pythonprov
-%pyrequires_eq	python-libs
-%pyrequires_eq	python-devel
+Requires:	python-devel
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %define		_noautocompressdoc	*.c
@@ -25,16 +37,40 @@ Cython lets you write code that mixes Python and C data types any way
 you want, and compiles it into a C extension for Python. Cython is
 based on Pyrex.
 
+This package contains Cython module for Python 2.x.
+
 %description -l pl.UTF-8
 Cython pozwala pisać kod zawierający dane Pythona i języka C połączone
 w jakikolwiek sposób i kompiluje to jako rozszerzenie C dla Pythona.
 Cython jest oparty na Pyreksie.
 
+Ten pakiet zawiera moduł Cython dla Pythona 2.x.
+
+%package -n python3-Cython
+Summary:	Language for writing Python Extension Modules (Python 3.x version)
+Summary(pl.UTF-8):	Język służący do pisania modułów rozszerzających Pythona (wersja dla Pythona 3.x)
+Group:		Libraries/Python
+Requires:	python3-devel
+
+%description -n python3-Cython
+Cython lets you write code that mixes Python and C data types any way
+you want, and compiles it into a C extension for Python. Cython is
+based on Pyrex.
+
+This package contains Cython module for Python 3.x.
+
+%description -n python3-Cython -l pl.UTF-8
+Pyrex pozwala pisać kod zawierający dane Pythona i języka C połączone
+w jakikolwiek sposób i kompiluje to jako rozszerzenie C dla Pythona.
+Cython jest oparty na Pyreksie.
+
+Ten pakiet zawiera moduł Cython dla Pythona 3.x.
+
 %package examples
 Summary:	Examples for Cython language
 Summary(pl.UTF-8):	Przykłady programów w języku Cython
 Group:		Libraries/Python
-Requires:	%{name} = %{version}-%{release}
+Obsoletes:	python3-Cython-examples
 
 %description examples
 This package contains example programs for Cython language.
@@ -46,26 +82,55 @@ Pakiet zawierający przykładowe programy napisane w języku Cython.
 %setup -q -n %{module}-%{version}
 
 %build
+%if %{with python2}
 CC="%{__cc}" \
 CFLAGS="%{rpmcflags}" \
-%{__python} setup.py build
+%{__python} setup.py build \
+	--build-base build-2
+%endif
+
+%if %{with python3}
+CC="%{__cc}" \
+CFLAGS="%{rpmcflags}" \
+%{__python3} setup.py build \
+	--build-base build-3
+%endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
 
-%{__python} setup.py install \
-	--root=$RPM_BUILD_ROOT \
-	--install-purelib=%{py_sitescriptdir} \
-	-O2
+%if %{with python3}
+%{__python3} setup.py \
+	build \
+		--build-base build-3 \
+	install \
+		--optimize=2 \
+		--skip-build \
+		--root=$RPM_BUILD_ROOT
+
+%{__mv} $RPM_BUILD_ROOT%{_bindir}/cython{,3}
+%{__mv} $RPM_BUILD_ROOT%{_bindir}/cygdb{,3}
+%endif
+
+%if %{with python2}
+%{__python} setup.py \
+	build \
+		--build-base build-2 \
+	install \
+		--optimize=2 \
+		--skip-build \
+		--root=$RPM_BUILD_ROOT
 
 find $RPM_BUILD_ROOT%{py_sitedir} -name "*.py" -a ! -name 'Lexicon.py' -exec rm -f {} \;
+%endif
 
 cp -a Demos/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%if %{with python2}
 %files
 %defattr(644,root,root,755)
 %doc COPYING.txt README.txt ToDo.txt USAGE.txt Doc/*.html Doc/*.c
@@ -74,7 +139,21 @@ rm -rf $RPM_BUILD_ROOT
 %{py_sitedir}/cython.py[co]
 %{py_sitedir}/Cython
 %{py_sitedir}/pyximport
-%{py_sitedir}/Cython-*.egg-info
+%{py_sitedir}/Cython-%{version}-py*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-Cython
+%defattr(644,root,root,755)
+%doc COPYING.txt README.txt ToDo.txt USAGE.txt Doc/*.html Doc/*.c
+%attr(755,root,root) %{_bindir}/cython3
+%attr(755,root,root) %{_bindir}/cygdb3
+%{py3_sitedir}/cython.py
+%{py3_sitedir}/__pycache__/cython.*
+%{py3_sitedir}/Cython
+%{py3_sitedir}/pyximport
+%{py3_sitedir}/Cython-%{version}-py*.egg-info
+%endif
 
 %files examples
 %defattr(644,root,root,755)
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-Cython.git/commitdiff/50da01819b5b05098052463ad8cb13601de5caa2



More information about the pld-cvs-commit mailing list