Conditionalize the Python 2 subpackage

This makes it possible to build without python2 support
by passing "--without python2" to rpmbuild
This commit is contained in:
Petr Viktorin 2018-03-28 16:10:07 +02:00
parent d0221b8af2
commit 654d113cc8

View File

@ -2,6 +2,12 @@
%global with_python3 1 %global with_python3 1
%endif %endif
%if 0%{?rhel} > 7
%bcond_with python2
%else
%bcond_without python2
%endif
%global upname Mako %global upname Mako
Name: python-mako Name: python-mako
@ -17,6 +23,7 @@ Summary: Mako template library for Python
URL: http://www.makotemplates.org/ URL: http://www.makotemplates.org/
Source0: https://bitbucket.org/zzzeek/mako/get/rel_%(echo %{version} | sed "s/\./_/g").tar.bz2 Source0: https://bitbucket.org/zzzeek/mako/get/rel_%(echo %{version} | sed "s/\./_/g").tar.bz2
%if %{with python2}
BuildRequires: python2-devel BuildRequires: python2-devel
BuildRequires: python2-pytest BuildRequires: python2-pytest
BuildRequires: python2-setuptools BuildRequires: python2-setuptools
@ -24,6 +31,7 @@ BuildRequires: python2-markupsafe
BuildRequires: python2-beaker BuildRequires: python2-beaker
BuildRequires: python2-nose BuildRequires: python2-nose
BuildRequires: python2-mock BuildRequires: python2-mock
%endif #{with python2}
%if 0%{?with_python3} %if 0%{?with_python3}
BuildRequires: python3-devel BuildRequires: python3-devel
@ -47,6 +55,7 @@ calling and scoping semantics.
%description %_description %description %_description
%if %{with python2}
%package -n python2-mako %package -n python2-mako
Summary: %summary Summary: %summary
Requires: python2-markupsafe Requires: python2-markupsafe
@ -57,6 +66,7 @@ Recommends: python2-beaker
%{?python_provide:%python_provide python2-mako} %{?python_provide:%python_provide python2-mako}
%description -n python2-mako %_description %description -n python2-mako %_description
%endif #{with python2}
%package doc %package doc
Summary: Documentation for the Mako template library for Python Summary: Documentation for the Mako template library for Python
@ -88,6 +98,10 @@ Recommends: python3-beaker
%{?python_provide:%python_provide python3-mako} %{?python_provide:%python_provide python3-mako}
%if %{without python2}
Obsoletes: python2-mako < %{version}-%{release}
%endif
%description -n python3-mako %description -n python3-mako
Mako is a template library written in Python. It provides a familiar, non-XML Mako is a template library written in Python. It provides a familiar, non-XML
syntax which compiles into Python modules for maximum performance. Mako's syntax which compiles into Python modules for maximum performance. Mako's
@ -110,7 +124,9 @@ cp -a . %{py3dir}
%endif # with_python3 %endif # with_python3
%build %build
%if %{with python2}
%{__python} setup.py build %{__python} setup.py build
%endif %{with python2}
%if 0%{?with_python3} %if 0%{?with_python3}
pushd %{py3dir} pushd %{py3dir}
@ -125,17 +141,23 @@ rm -rf %{buildroot}
%if 0%{?with_python3} %if 0%{?with_python3}
pushd %{py3dir} pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot} %{__python3} setup.py install --skip-build --root %{buildroot}
%if %{with python2}
mv %{buildroot}/%{_bindir}/mako-render %{buildroot}/%{_bindir}/python3-mako-render mv %{buildroot}/%{_bindir}/mako-render %{buildroot}/%{_bindir}/python3-mako-render
%endif
popd popd
%endif # with_python3 %endif # with_python3
%if %{with python2}
%{__python} setup.py install --skip-build --root %{buildroot} %{__python} setup.py install --skip-build --root %{buildroot}
%endif #{with python2}
# These are supporting files for building the docs. No need to ship # These are supporting files for building the docs. No need to ship
rm -rf doc/build rm -rf doc/build
%check %check
%if %{with python2}
python2 setup.py test python2 setup.py test
%endif #{with python2}
%if 0%{?with_python3} %if 0%{?with_python3}
pushd %{py3dir} pushd %{py3dir}
@ -143,20 +165,25 @@ python3 setup.py test
popd popd
%endif %endif
%if %{with python2}
%files -n python2-mako %files -n python2-mako
%defattr(-,root,root,-) %defattr(-,root,root,-)
%license LICENSE %license LICENSE
%doc CHANGES README.rst examples %doc CHANGES README.rst examples
%{_bindir}/mako-render %{_bindir}/mako-render
%{python_sitelib}/* %{python_sitelib}/*
%endif %{with python2}
%if 0%{?with_python3} %if 0%{?with_python3}
%files -n python3-mako %files -n python3-mako
%defattr(-,root,root,-) %defattr(-,root,root,-)
%license LICENSE %license LICENSE
%doc CHANGES README.rst examples %doc CHANGES README.rst examples
%if %{with python2}
%{_bindir}/python3-mako-render %{_bindir}/python3-mako-render
%else
%{_bindir}/mako-render
%endif
%{python3_sitelib}/* %{python3_sitelib}/*
%endif %endif
@ -168,6 +195,7 @@ popd
* Wed Mar 28 2018 Petr Viktorin <pviktori@redhat.com> - 1.0.6-9 * Wed Mar 28 2018 Petr Viktorin <pviktori@redhat.com> - 1.0.6-9
- Make python-beaker an optional dependency - Make python-beaker an optional dependency
- Add missing python_provide for python3-mako - Add missing python_provide for python3-mako
- Conditionalize the Python 2 subpackage
* Mon Feb 12 2018 Iryna Shcherbina <ishcherb@redhat.com> - 1.0.6-8 * Mon Feb 12 2018 Iryna Shcherbina <ishcherb@redhat.com> - 1.0.6-8
- Update Python 2 dependency declarations to new packaging standards - Update Python 2 dependency declarations to new packaging standards