#
# Conditional build:
%bcond_without tests # do not perform "make test"
+%bcond_without python3 # CPython 3.x module
%define module template
Summary: -
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
%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 \
--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}
%{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