File python-jinja2-cli.spec of Package python-jinja2-cli
#
# spec file for package python-jinja2-cli
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-jinja2-cli
Version: 0.8.2
Release: 0
Summary: A CLI interface to Jinja2
License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://github.com/mattrobenolt/jinja2-cli
Source: https://files.pythonhosted.org/packages/source/j/jinja2-cli/jinja2-cli-%{version}.tar.gz
# Template test file, and test
Source1: https://raw.githubusercontent.com/mattrobenolt/jinja2-cli/master/tests/files/template.j2
Source2: https://raw.githubusercontent.com/mattrobenolt/jinja2-cli/master/tests/test_jinja2cli.py
BuildRequires: %{python_module Jinja2}
BuildRequires: %{python_module PyYAML}
BuildRequires: %{python_module WebTest}
BuildRequires: %{python_module devel}
# Testing requirements:
BuildRequires: %{python_module flake8}
BuildRequires: %{python_module pytest-cov}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module toml}
BuildRequires: %{python_module xmltodict}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-Jinja2
Requires: python-PyYAML
Requires: python-toml
Requires: python-xmltodict
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
%python_subpackages
%description
jinja2 client interface for Jinja2 a template engine written
in pure Python.
If PyYAML is present, you can use YAML as an input data source.
If toml is present, you can use TOML as an input data source.
Here some way to use it :
jinja2 helloworld.tmpl data.json --format=json
cat data.json | jinja2 helloworld.tmpl
curl -s http://httpbin.org/ip | jinja2 helloip.tmpl
curl -s http://httpbin.org/ip | jinja2 helloip.tmpl > helloip.html
%prep
%setup -q -n jinja2-cli-%{version}
mkdir -p tests/files
cp -av %{SOURCE1} tests/files
cp -av %{SOURCE2} tests/
#Remove the limits for flake8<3
sed -i 's/flake8<3/flake8/g' setup.py
#Fix install tests in setup
sed -i 's,packages=find_packages(exclude=["tests"]),packages=find_packages(),g' setup.py
%build
%python_build
%install
%python_install
%python_expand %fdupes -s %{buildroot}%{$python_sitelib}
#Upstream error they install tests, will be fixed later
%python_expand rm -frv %{buildroot}%{$python_sitelib}/tests
%python_clone -a %{buildroot}%{_bindir}/jinja2
%check
%{python_expand #multiple line we need to go into build
export PYTHONPATH=%{buildroot}%{$python_sitelib}
py.test-%{$python_version} -v
rm -fr .pytest_cache
}
%post
%python_install_alternative jinja2
%postun
%python_uninstall_alternative jinja2
%files %python_files
%defattr(-,root,root,-)
%license LICENSE
%doc README.md
%python_alternative %{_bindir}/jinja2
%{python_sitelib}/jinja2cli/
%{python_sitelib}/jinja2_cli-%{version}-py%{python_version}.egg-info
%changelog