# RHEL 8's GTK bindings are only for its Python 3.6, so there j2live runs from # a private Python 3.12 environment in /opt/j2live, built offline from the # vendored packages in Source1. Elsewhere it's an ordinary Python package. %if 0%{?rhel} == 8 %bcond_without bundled_python %else %bcond_with bundled_python %endif %global appid com.wrouesnel.j2live Name: j2live Version: 0.1.0 Release: 1%{?dist} Summary: Live preview editor for Jinja2 and Ansible templates License: GPL-2.0-or-later URL: https://github.com/wrouesnel/j2live Source0: %{name}-%{version}.tar.gz %if %{with bundled_python} # Generated by packaging/rpm/make-vendor.sh Source1: %{name}-vendor-%{version}.tar.gz %endif BuildRequires: desktop-file-utils Requires: gtk3 Requires: gtksourceview4 Suggests: ansible-core %if %{with bundled_python} %global venv /opt/%{name} %global python312 /usr/bin/python3.12 BuildRequires: python3.12-devel BuildRequires: gcc BuildRequires: gobject-introspection-devel BuildRequires: cairo-devel BuildRequires: cairo-gobject-devel BuildRequires: pkgconf-pkg-config BuildRequires: ninja-build BuildRequires: binutils Requires: python3.12 Requires: gobject-introspection Requires: cairo-gobject # Everything under /opt/j2live is private to it %global __provides_exclude_from ^%{venv}/.*$ %global __requires_exclude_from ^%{venv}/.*$ # The bundled code is Python 3.12; keep RHEL 8's Python 3.6 tooling off it %global __brp_python_bytecompile %{nil} %global __brp_mangle_shebangs_exclude_from ^%{venv}/.*$ %global debug_package %{nil} %else BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros BuildRequires: python3-hatchling BuildRequires: python3-pip Requires: python3-gobject %endif %description j2live shows a Jinja2 template, the YAML variables it is rendered with and the rendered output side by side, re-rendering as you type. Errors are reported with line numbers and whitespace in the output is made visible. Templates can be rendered exactly as Ansible's template module renders them, using the ansible-core from a Python environment of your choosing. An Ansible action plugin is included that opens templates in j2live while a playbook runs. %prep %autosetup -n %{name}-%{version} %if %{with bundled_python} %setup -q -T -D -a 1 -n %{name}-%{version} (cd %{name}-vendor-%{version} && sha256sum -c --quiet SHA256SUMS) %endif %build %if %{without bundled_python} %pyproject_wheel %endif %install %if %{with bundled_python} vendor="$PWD/%{name}-vendor-%{version}" %{python312} -m venv %{buildroot}%{venv} pip="%{buildroot}%{venv}/bin/python -m pip --disable-pip-version-check --no-cache-dir" # meson-python runs the meson installed in the venv export PATH="%{buildroot}%{venv}/bin:$PATH" # Build tools first, then build everything else with them and no network $pip install --no-index --find-links "$vendor" \ setuptools wheel meson meson-python hatchling # pip builds everything before installing anything, and pygobject's build # needs pycairo installed $pip install --no-index --find-links "$vendor" --no-build-isolation pycairo $pip install --no-index --find-links "$vendor" --no-build-isolation \ pygobject jinja2 ruamel.yaml structlog $pip install --no-index --find-links "$vendor" --no-build-isolation --no-deps . $pip uninstall -y meson meson-python pyproject-metadata hatchling pathspec pluggy \ trove-classifiers packaging tomlkit setuptools wheel pip # There's no debuginfo package for the bundled extensions, and their debug # info records the build root find %{buildroot}%{venv} -name '*.so' -exec strip --strip-unneeded {} + # The venv was built in the buildroot; make it refer to where it's installed grep -rlI --null "%{buildroot}" %{buildroot}%{venv} | xargs -0 -r sed -i "s|%{buildroot}||g" find %{buildroot}%{venv} -name __pycache__ -prune -exec rm -rf {} + %{buildroot}%{venv}/bin/python -m compileall -q -s %{buildroot} -p / \ %{buildroot}%{venv}/lib/python3.12/site-packages mkdir -p %{buildroot}%{_bindir} ln -s %{venv}/bin/%{name} %{buildroot}%{_bindir}/%{name} %else %pyproject_install %pyproject_save_files %{name} %endif install -Dpm 0644 data/%{appid}.desktop %{buildroot}%{_datadir}/applications/%{appid}.desktop install -Dpm 0644 extras/ansible/action_plugins/j2live_template.py \ %{buildroot}%{_datadir}/%{name}/ansible/action_plugins/j2live_template.py %check desktop-file-validate %{buildroot}%{_datadir}/applications/%{appid}.desktop %if %{with bundled_python} %files %{venv} %else %files -f %{pyproject_files} %endif %doc README.md extras/ansible/README.md %{_bindir}/%{name} %{_datadir}/applications/%{appid}.desktop %{_datadir}/%{name} %changelog * Sat Oct 03 2026 Will Rouesnel - 0.1.0-1 - Initial package