[projects/template-specs] py3 samples, rather dirty and unorganized
glen
glen at pld-linux.org
Sat Apr 6 00:04:09 CEST 2013
commit d328d9432c9ef5a35ec1971b1bb5202b8abe0e64
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Sat Apr 6 01:03:33 2013 +0300
py3 samples, rather dirty and unorganized
python.spec | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
---
diff --git a/python.spec b/python.spec
index 717f5e1..ba54006 100644
--- a/python.spec
+++ b/python.spec
@@ -1,6 +1,7 @@
#
# Conditional build:
%bcond_without tests # do not perform "make test"
+%bcond_without python3 # CPython 3.x module
%define module template
Summary: -
@@ -20,6 +21,13 @@ BuildRequires: python-distribute
BuildRequires: rpm-pythonprov
# if py_postclean is used
BuildRequires: rpmbuild(macros) >= 1.219
+# when python3 present
+BuildRequires: sed >= 4.0
+%if %{with python3}
+BuildRequires: python3-devel
+BuildRequires: python3-distribute
+BuildRequires: python3-modules
+%endif
#Requires: python-libs
Requires: python-modules
#BuildArch: noarch
@@ -29,20 +37,63 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description -l pl.UTF-8
+%package apidoc
+Summary: %{module} API documentation
+Summary(pl.UTF-8): Dokumentacja API %{module}
+Group: Documentation
+
+%description apidoc
+API documentation for %{module}.
+
+%description apidoc -l pl.UTF-8
+Dokumentacja API %{module}.
+
%prep
%setup -q -n %{module}-%{version}
# fix #!/usr/bin/env python -> #!/usr/bin/python:
#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
+%if %{with python3}
+rm -rf build-3
+set -- *
+install -d build-3
+cp -a "$@" build-3
+find build-3 -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
+%endif
+
%build
+%if %{with python2}
+%{__python} setup.py build --build-base build-2
+%endif
+%if %{with python3}
+%{__python3} setup.py build --build-base build-3
+%endif
+
# CC/CFLAGS is only for arch packages - remove on noarch packages
CC="%{__cc}" \
CFLAGS="%{rpmcflags}" \
%{__python} setup.py build
+%{__python} setup.py \
+ build -b build-2
%{?with_tests:%{__python} setup.py test}
+%if %{with python3}
+%{__python3} setup.py \
+ build -b build-3
+
+%if %{with tests}
+%{__python3} setup.py test
+%endif
+%endif
+
+%if %{with doc}
+cd docs
+%{__make} -j1 html
+rm -rf _build/html/_sources
+%endif
+
%install
rm -rf $RPM_BUILD_ROOT
%{__python} setup.py install \
@@ -50,6 +101,36 @@ rm -rf $RPM_BUILD_ROOT
--optimize=2 \
--root=$RPM_BUILD_ROOT
+%{__python} -- setup.py \
+ build -b build-2 \
+ install \
+ --root=$RPM_BUILD_ROOT \
+ --optimize=2
+
+%if %{with python2}
+%{__python} setup.py \
+ build --build-base build-2 \
+ install \
+ --root=$RPM_BUILD_ROOT \
+ --optimize=2
+
+%py_postclean
+%endif
+
+%{__python3} -- setup.py \
+ build -b build-3 \
+ install \
+ --root=$RPM_BUILD_ROOT \
+ --optimize=2
+
+%if %{with python3}
+%{__python3} setup.py \
+ build --build-base build-3 \
+ install \
+ --root=$RPM_BUILD_ROOT \
+ --optimize=2
+%endif
+
install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
@@ -71,3 +152,25 @@ rm -rf $RPM_BUILD_ROOT
%{py_sitedir}/TEMPLATE-*.egg-info
%endif
%{_examplesdir}/%{name}-%{version}
+
+%if %{with python2}
+%files
+%defattr(644,root,root,755)
+%doc AUTHORS CHANGES LICENSE
+%{py_sitescriptdir}/%{module}
+%{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-%{module}
+%defattr(644,root,root,755)
+%doc AUTHORS CHANGES LICENSE
+%{py3_sitescriptdir}/%{module}
+%{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
+%endif
+
+%if %{with doc}
+%files apidoc
+%defattr(644,root,root,755)
+%doc docs/_build/html/*
+%endif
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/template-specs.git/commitdiff/d328d9432c9ef5a35ec1971b1bb5202b8abe0e64
More information about the pld-cvs-commit
mailing list