Use new Python packaging guidelines.

Jinja2 version 3 does not support Python 2 anymore.
This commit is contained in:
Thomas Moschny 2021-11-15 21:11:41 +01:00
parent 6f194bb41b
commit 652a40287b

View File

@ -2,7 +2,7 @@
Name: python-jinja2
Version: 3.0.1
Release: 3%{?dist}
Release: 4%{?dist}
Summary: General purpose template engine
License: BSD
URL: https://palletsprojects.com/p/jinja/
@ -13,34 +13,14 @@ Patch1: https://github.com/pallets/jinja/pull/1525.patch
# Tests: Adapt expected traceback regexes for Python 3.11.0a1
Patch2: https://github.com/pallets/jinja/pull/1527.patch
%if 0%{?fedora} || 0%{?rhel} > 7
# Enable python3 build by default
%bcond_without python3
%else
%bcond_with python3
%endif
%if 0%{?fedora} > 33 || 0%{?rhel} > 7
# Disable python2 build by default
%bcond_with python2
%else
%bcond_without python2
%endif
# Enable building without docs to avoid a circular dependency between this
# and python-sphinx:
%bcond_without docs
%if 0%{?fedora} || 0%{?rhel} > 7
%bcond_without async
%else
%bcond_with async
%endif
BuildArch: noarch
%description
Jinja2 is a template engine written in pure Python. It provides a
%global _description %{expand:
Jinja2 is a template engine written in pure Python. It provides a
Django inspired non-XML syntax but supports inline expressions and an
optional sandboxed environment.
@ -48,42 +28,13 @@ If you have any exposure to other text-based template languages, such
as Smarty or Django, you should feel right at home with Jinja2. It's
both designer and developer friendly by sticking to Python's
principles and adding functionality useful for templating
environments.
environments.}
%description %_description
%if %{with python2}
%package -n python2-jinja2
Summary: General purpose template engine for python2
BuildRequires: python2-devel
BuildRequires: python2-setuptools
BuildRequires: python2-babel >= 0.8
BuildRequires: python2-markupsafe >= 0.23
Requires: python2-babel >= 0.8
Requires: python2-markupsafe >= 0.23
Requires: python2-setuptools
%{?python_provide:%python_provide python2-jinja2}
%description -n python2-jinja2
Jinja2 is a template engine written in pure Python. It provides a
Django inspired non-XML syntax but supports inline expressions and an
optional sandboxed environment.
If you have any exposure to other text-based template languages, such
as Smarty or Django, you should feel right at home with Jinja2. It's
both designer and developer friendly by sticking to Python's
principles and adding functionality useful for templating
environments.
%endif # with python2
%if %{with python3}
%package -n python3-jinja2
Summary: General purpose template engine for python3
Summary: %{summary}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-babel >= 0.8
BuildRequires: python3-markupsafe >= 0.23
BuildRequires: python3-pytest
%if %{with docs}
BuildRequires: %{_bindir}/sphinx-build-3
BuildRequires: make
@ -92,96 +43,51 @@ BuildRequires: python3-sphinxcontrib-log-cabinet
BuildRequires: python3-sphinx-issues
%endif
%description -n python3-jinja2
Jinja2 is a template engine written in pure Python. It provides a
Django inspired non-XML syntax but supports inline expressions and an
optional sandboxed environment.
%description -n python3-jinja2 %_description
If you have any exposure to other text-based template languages, such
as Smarty or Django, you should feel right at home with Jinja2. It's
both designer and developer friendly by sticking to Python's
principles and adding functionality useful for templating
environments.
%{?python_extras_subpkg:%python_extras_subpkg -n python3-jinja2 -i%{python3_sitelib}/Jinja2-*.egg-info i18n}
%endif # with python3
%pyproject_extras_subpkg -n python3-jinja2 i18n
%prep
%autosetup -p1 -n %{srcname}-%{version}
# cleanup
find . -name '*.pyo' -o -name '*.pyc' -delete
%generate_buildrequires
%pyproject_buildrequires -x i18n
%build
%if %{with python2}
%py2_build
%endif # with python2
%if %{with python3}
%py3_build
%pyproject_wheel
%if %{with docs}
make -C docs html PYTHONPATH=$(pwd)/src SPHINXBUILD=sphinx-build-3
# remove hidden file
rm -rf docs/_build/html/.buildinfo
%endif # with docs
%endif # with python3
rm -rvf docs/_build/html/.buildinfo
%endif
%install
%if %{with python2}
%py2_install
# these files are valid only on Python 3.6+
rm %{buildroot}%{python2_sitelib}/jinja2/asyncsupport.py
rm %{buildroot}%{python2_sitelib}/jinja2/asyncfilters.py
%endif # with python2
%if %{with python3}
%py3_install
%if ! %{with async}
# these files are valid only on Python 3.6+
rm %{buildroot}%{python3_sitelib}/jinja2/asyncsupport.py
rm %{buildroot}%{python3_sitelib}/jinja2/asyncfilters.py
%endif # ! with async
%endif # with python3
%pyproject_install
%pyproject_save_files jinja2
%check
%if %{with python3}
PYTHONPATH=$(pwd)/src %{__python3} -m pytest tests
%endif # with python3
%pytest tests
%if %{with python2}
%files -n python2-jinja2
%doc CHANGES.rst
%doc ext
%doc examples
%license LICENSE.rst
%if %{with docs}
%doc docs/_build/html
%endif
%{python2_sitelib}/jinja2/
%{python2_sitelib}/Jinja2-*.egg-info/
%endif # with python2
%if %{with python3}
%files -n python3-jinja2
%files -n python3-jinja2 -f %{pyproject_files}
%doc CHANGES.rst
%doc examples
%license LICENSE.rst
%if %{with docs}
%doc docs/_build/html
%endif
%{python3_sitelib}/jinja2/
%{python3_sitelib}/Jinja2-*.egg-info/
%endif # with python3
%changelog
* Mon Nov 15 2021 Thomas Moschny <thomas.moschny@gmx.de> - 3.0.1-4
- Use new Python packaging guidelines.
- Jinja2 version 3 does not support Python 2 anymore.
* Wed Nov 10 2021 Karolina Surma <ksurma@redhat.com> - 3.0.1-3
- Don't explicitly declare runtime dependencies when building for Python 3
- Declare jinja2+i18n extra to map the upstream package structure