Modernize the specfile

- Use %bcond, which can be overridden when building manually
- Don't use obsolete features: %{py3dir}, clearing buildroot,
  %defattr
- Use proper macros for %{__python2}, %{python2_sitelib}
This commit is contained in:
Petr Viktorin 2018-03-28 16:20:43 +02:00
parent 654d113cc8
commit 33ca828644

View File

@ -1,5 +1,7 @@
%if 0%{?fedora} || 0%{?rhel} >= 8 %if 0%{?fedora} || 0%{?rhel} >= 8
%global with_python3 1 %bcond_without python3
%else
%bcond_with python3
%endif %endif
%if 0%{?rhel} > 7 %if 0%{?rhel} > 7
@ -33,7 +35,7 @@ BuildRequires: python2-nose
BuildRequires: python2-mock BuildRequires: python2-mock
%endif #{with python2} %endif #{with python2}
%if 0%{?with_python3} %if %{with python3}
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: python3-pytest BuildRequires: python3-pytest
BuildRequires: python3-setuptools BuildRequires: python3-setuptools
@ -41,7 +43,7 @@ BuildRequires: python3-markupsafe
BuildRequires: python3-beaker BuildRequires: python3-beaker
BuildRequires: python3-mock BuildRequires: python3-mock
BuildRequires: python3-nose BuildRequires: python3-nose
%endif # if with_python3 %endif #{with python3}
%global _description\ %global _description\
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\
@ -87,7 +89,7 @@ calling and scoping semantics.
This package contains documentation in text and HTML formats. This package contains documentation in text and HTML formats.
%if 0%{?with_python3} %if %{with python3}
%package -n python3-mako %package -n python3-mako
Summary: Mako template library for Python 3 Summary: Mako template library for Python 3
Group: Development/Languages Group: Development/Languages
@ -113,70 +115,47 @@ and flexible models available, while also maintaining close ties to Python
calling and scoping semantics. calling and scoping semantics.
This package contains the mako module built for use with python3. This package contains the mako module built for use with python3.
%endif # with_python3 %endif #{with python3}
%prep %prep
%autosetup -n zzzeek-mako-8e83c7561e3c %autosetup -n zzzeek-mako-8e83c7561e3c
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif # with_python3
%build %build
%if %{with python2} %{?with_python2:%py2_build}
%{__python} setup.py build %{?with_python3:%py3_build}
%endif %{with python2}
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif # with_python3
%install %install
rm -rf %{buildroot} %{?with_python3:%py3_install}
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot}
%if %{with python2} %if %{with python2}
mv %{buildroot}/%{_bindir}/mako-render %{buildroot}/%{_bindir}/python3-mako-render mv %{buildroot}/%{_bindir}/mako-render %{buildroot}/%{_bindir}/python3-mako-render
%endif %endif
popd
%endif # with_python3
%if %{with python2} %{?with_python2:%py2_install}
%{__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} %if %{with python2}
python2 setup.py test %{__python2} setup.py test
%endif #{with python2} %endif #{with python2}
%if 0%{?with_python3} %if %{with python3}
pushd %{py3dir} %{__python3} setup.py test
python3 setup.py test
popd
%endif %endif
%if %{with python2} %if %{with python2}
%files -n python2-mako %files -n python2-mako
%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}/* %{python2_sitelib}/*
%endif %{with python2} %endif %{with python2}
%if 0%{?with_python3} %if 0%{with python3}
%files -n python3-mako %files -n python3-mako
%defattr(-,root,root,-)
%license LICENSE %license LICENSE
%doc CHANGES README.rst examples %doc CHANGES README.rst examples
%if %{with python2} %if %{with python2}
@ -196,6 +175,7 @@ popd
- 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 - Conditionalize the Python 2 subpackage
- Modernize the specfile
* 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