[packages/python-markupsafe] build python3 package

glen glen at pld-linux.org
Wed Sep 25 22:46:35 CEST 2013


commit d1b3c5155480d90256ff75e92ec2ac4b8c8ac326
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Wed Sep 25 23:42:43 2013 +0300

    build python3 package

 python-MarkupSafe.spec | 90 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 81 insertions(+), 9 deletions(-)
---
diff --git a/python-MarkupSafe.spec b/python-MarkupSafe.spec
index 8045f50..70aa5c5 100644
--- a/python-MarkupSafe.spec
+++ b/python-MarkupSafe.spec
@@ -1,53 +1,125 @@
+#
+# Conditional build:
+%bcond_without	tests	# do not perform "make test"
+%bcond_without	python2 # CPython 2.x module
+%bcond_without	python3 # CPython 3.x module
+
 %define 	module	MarkupSafe
 Summary:	Implements a XML/HTML/XHTML Markup safe string for Python
 Name:		python-%{module}
 Version:	0.15
-Release:	1
+Release:	2
 License:	BSD
 Group:		Development/Languages/Python
 Source0:	http://pypi.python.org/packages/source/M/MarkupSafe/%{module}-%{version}.tar.gz
 # Source0-md5:	4e7c4d965fe5e033fa2d7bb7746bb186
 URL:		http://www.pocoo.org/
-BuildRequires:	python-devel
-BuildRequires:	python-setuptools
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.219
+%if %{with python2}
+BuildRequires:	python-devel
+BuildRequires:	python-distribute
+%endif
+%if %{with python3}
+BuildRequires:	python-2to3
+BuildRequires:	python3-devel
+BuildRequires:	python3-distribute
+%endif
 Requires:	python-modules
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
 Implements a XML/HTML/XHTML Markup safe string for Python.
 
+%package -n python3-markupsafe
+Summary:	Implements a XML/HTML/XHTML Markup safe string for Python
+Group:		Development/Languages
+
+%description -n python3-markupsafe
+Implements a XML/HTML/XHTML Markup safe string for Python.
+
 %prep
-%setup -q -n %{module}-%{version}
+%setup -qc
+mv %{module}-%{version} py2
+# for %doc
+cp -p py2/{AUTHORS,LICENSE,README.rst} .
+
+%if %{with python3}
+cp -a py2 py3
+2to3 --write --nobackups py3
+%endif
 
 %build
+%if %{with python2}
+cd py3
 # CFLAGS is only for arch packages - remove on noarch packages
 CC="%{__cc}" \
 CFLAGS="%{rpmcflags}" \
 %{__python} setup.py build
+%{?with_tests:%{__python} setup.py test}
+cd ..
+%endif
+
+%if %{with python3}
+cd py3
+CC="%{__cc}" \
+CFLAGS="%{rpmcflags}" \
+%{__python3} setup.py build
+%{?with_tests:%{__python3} setup.py test}
+cd ..
+%endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
+%if %{with python2}
+cd py2
 %{__python} setup.py install \
 	--optimize=2 \
 	--root=$RPM_BUILD_ROOT
 
+# C code errantly gets installed
 %{__rm} $RPM_BUILD_ROOT%{py_sitedir}/markupsafe/_speedups.c
-
 %py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
 %py_comp $RPM_BUILD_ROOT%{py_sitedir}
 %py_postclean
+cd ..
+%endif
+
+%if %{with python3}
+cd py3
+%{__python3} setup.py install \
+	--optimize=2 \
+	--root=$RPM_BUILD_ROOT
+
+
+# err the unversioned one is duplicate
+%{__rm} -r $RPM_BUILD_ROOT%{py3_sitedir}/MarkupSafe.egg-info
+
+# C code errantly gets installed
+%{__rm} $RPM_BUILD_ROOT%{py3_sitedir}/markupsafe/_speedups.c
+cd ..
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%if %{with python2}
 %files
 %defattr(644,root,root,755)
-%doc README.rst
-%{py_sitedir}/markupsafe/*.py[co]
+%doc AUTHORS LICENSE README.rst
 %dir %{py_sitedir}/markupsafe
+%{py_sitedir}/markupsafe/*.py[co]
 %attr(755,root,root) %{py_sitedir}/markupsafe/*.so
-%if "%{py_ver}" > "2.4"
-%{py_sitedir}/%{module}-*.egg-info
+%{py_sitedir}/MarkupSafe-%{version}-py*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-markupsafe
+%defattr(644,root,root,755)
+%doc AUTHORS LICENSE README.rst
+%dir %{py3_sitedir}/markupsafe
+%{py3_sitedir}/markupsafe/*.py
+%{py3_sitedir}/markupsafe/__pycache__
+%attr(755,root,root) %{py3_sitedir}/markupsafe/*.so
+%{py3_sitedir}/MarkupSafe-%{version}-py*.egg-info
 %endif
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-markupsafe.git/commitdiff/a8646d2c77b16d4b110ddb0d6639ce6e9c956af1



More information about the pld-cvs-commit mailing list