%global pkgname anytemplate %if 0%{?fedora} || 0%{?rhel} > 7 || 0%{?epel} > 7 %global with_python3 1 %endif %global desc \ Python library works as an abstraction layer for various python template\ engines and rendering libraries, and provide a few very simple and easily\ understandable APIs to render templates.\ \ Also a CLI tool called anytemplate_cli is provided to render templates written\ in these template languages. Name: python-%{pkgname} Version: 0.1.5 Release: 2%{?dist} Summary: Python library provides common APIs for various template engines Group: Development/Tools License: MIT URL: https://github.com/ssato/python-anytemplate Source0: %{pkgname}-%{version}.tar.gz BuildArch: noarch %if 0%{?with_python3} BuildRequires: python3-devel BuildRequires: python3-setuptools %else BuildRequires: python2-setuptools BuildRequires: python2-devel %endif %description %{desc} %if 0%{?with_python3} %package -n python3-%{pkgname} Summary: %{summary} Requires: python3-PyYAML Requires: python3-jinja2 Requires: python3-anytemplate %{?python_provide:%python_provide python3-%{pkgname}} %description -n python3-%{pkgname} %{desc} %else %package -n python2-%{pkgname} Summary: %{summary} Requires: PyYAML Requires: python2-jinja2 Requires: python2-anytemplate %{?python_provide:%python_provide python2-%{pkgname}} %description -n python2-%{pkgname} %{desc} %endif %prep %autosetup -n %{pkgname}-%{version} %build %if 0%{?with_python3} %py3_build %else %py2_build %endif %install %if 0%{?with_python3} %py3_install %else %py2_install # Dirty hacks. test -d %{buildroot}%{python_sitelib}/%{pkgname} || { cp -a %{pkgname} %{buildroot}%{python_sitelib}/ } test -d %{buildroot}/usr/bin || { install -d %{buildroot}/usr/bin cat << EOF > %{buildroot}/usr/bin/anytemplate_cli #! /usr/bin/python import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.exit( load_entry_point('anytemplate', 'console_scripts', 'anytemplate_cli')() ) EOF } chmod +x %{buildroot}/usr/bin/anytemplate_cli %endif %if 0%{?with_python3} %files -n python3-%{pkgname} %{python3_sitelib}/%{pkgname}* %else %files -n python2-%{pkgname} %{python_sitelib}/%{pkgname}* %endif %doc README.rst examples %{_bindir}/* %changelog * Fri Nov 2 2018 Satoru SATOH - 0.1.5-2 - Cleanups and fixes of the RPM SPEC * Tue Aug 7 2018 Satoru SATOH - 0.1.5-1 - New upstream release * Tue May 1 2018 Satoru SATOH - 0.1.4-1 - New upstream release * Fri May 1 2015 Satoru SATOH - 0.0.1-1 - Initial packaging