%global pypi_name renderspec
%global common_desc\
renderspec is a tool to convert a .spec.j2 Jinja2 template to a rpm .spec file\
which is usable for different distributions and follow their policies and\
processes.
# Python3 support for Fedora
%if 0%{?fedora}
%global with_python3 1
%endif
Name: python-%{pypi_name}
Version: 1.7.0
Release: 6%{?dist}
Summary: Jinja2 template renderer for generating .spec files
License: ASL 2.0
URL: http://docs.openstack.org/developer/renderspec/
Source0: https://files.pythonhosted.org/packages/source/r/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
BuildArch: noarch
%description
%{common_desc}
%package -n python2-%{pypi_name}
Summary: %{summary}
%{?python_provide:%python_provide python2-%{pypi_name}}
BuildRequires: python2-devel
BuildRequires: %{py2_dist pbr}
BuildRequires: %{py2_dist testrepository}
BuildRequires: %{py2_dist testresources}
BuildRequires: %{py2_dist testtools}
BuildRequires: %{py2_dist ddt}
BuildRequires: %{py2_dist mock}
BuildRequires: %{py2_dist Sphinx}
BuildRequires: %{py2_dist oslosphinx}
BuildRequires: %{py2_dist setuptools}
# Required for tests
BuildRequires: %{py2_dist packaging}
BuildRequires: %{py2_dist pymod2pkg}
BuildRequires: %{py2_dist PyYAML}
Requires: %{py2_dist Jinja2} >= 2.8
Requires: %{py2_dist pymod2pkg} >= 0.7.0
Requires: %{py2_dist PyYAML} >= 3.10
Requires: %{py2_dist packaging} >= 16.5
Requires: %{py2_dist six} >= 1.9.0
Requires: %{py2_dist setuptools}
%description -n python2-%{pypi_name}
%{common_desc}
%if 0%{?with_python3}
%package -n python3-%{pypi_name}
Summary: %{summary}
%{?python_provide:%python_provide python3-%{pypi_name}}
BuildRequires: python3-devel
BuildRequires: %{py3_dist pbr}
BuildRequires: %{py3_dist testrepository}
BuildRequires: %{py3_dist testresources}
BuildRequires: %{py3_dist testtools}
BuildRequires: %{py3_dist ddt}
BuildRequires: %{py3_dist mock}
BuildRequires: %{py3_dist Sphinx}
BuildRequires: %{py3_dist oslosphinx}
BuildRequires: %{py3_dist setuptools}
# Required for tests
BuildRequires: %{py3_dist packaging}
BuildRequires: %{py3_dist pymod2pkg}
BuildRequires: %{py3_dist PyYAML}
Requires: %{py3_dist Jinja2} >= 2.8
Requires: %{py3_dist pymod2pkg} >= 0.7.0
Requires: %{py3_dist PyYAML} >= 3.10
Requires: %{py3_dist packaging} >= 16.5
Requires: %{py3_dist six} >= 1.9.0
Requires: %{py3_dist setuptools}
%description -n python3-%{pypi_name}
%{common_desc}
%endif
%package -n python-%{pypi_name}-doc
Summary: renderspec documentation
%description -n python-%{pypi_name}-doc
Documentation for renderspec
%prep
%autosetup -n %{pypi_name}-%{version}
# Let's handle dependencies ourselves
rm -f *requirements.txt
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
# remove shebangs
find -type f -a \( -name '*.py' -o -name 'py.*' \) \
-exec sed -i '1{/^#!/d}' {} \; \
%build
%py2_build
%if 0%{?with_python3}
%py3_build
%endif
# generate html docs
sphinx-build doc/source html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}
%install
# Must do the subpackages' install first because the scripts in /usr/bin are
# overwritten with every setup.py install.
%if 0%{?with_python3}
%py3_install
cp %{buildroot}/%{_bindir}/renderspec %{buildroot}/%{_bindir}/renderspec-%{python3_version}
ln -s %{_bindir}/renderspec-%{python3_version} %{buildroot}/%{_bindir}/renderspec-3
%endif
%py2_install
cp %{buildroot}/%{_bindir}/renderspec %{buildroot}/%{_bindir}/renderspec-%{python2_version}
ln -s %{_bindir}/renderspec-%{python2_version} %{buildroot}/%{_bindir}/renderspec-2
%check
PYTHON=python2 %{__python2} setup.py test
%if 0%{?with_python3}
rm -rf .testrepository
PYTHON=python3 %{__python3} setup.py test
%endif
%files -n python2-%{pypi_name}
%license LICENSE
%doc README.rst
%{_bindir}/renderspec
%{_bindir}/renderspec-2
%{_bindir}/renderspec-%{python2_version}
%{python2_sitelib}/%{pypi_name}
%{python2_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%if 0%{?with_python3}
%files -n python3-%{pypi_name}
%license LICENSE
%doc README.rst
%{_bindir}/renderspec-3
%{_bindir}/renderspec-%{python3_version}
%{python3_sitelib}/%{pypi_name}
%{python3_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%endif
%files -n python-%{pypi_name}-doc
%license LICENSE
%doc html
%changelog
* Tue Aug 07 2018 Javier Peña <jpena@redhat.com> - 1.7.0-6
- Fixed Rawhide build (bz#1605872)
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 1.7.0-4
- Rebuilt for Python 3.7
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Fri Sep 22 2017 Javier Peña <jpena@redhat.com> - 1.7.0-2
- Fixes to issues found during review
- Use py2_dist and py3_dist for requirements
* Wed Sep 20 2017 Javier Peña <jpena@redhat.com> - 1.7.0-1
- Initial package.