From 874e4fdb5b79f003c3bda3237ffbc6e9a62c89f3 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Apr 12 2016 09:57:36 +0000 Subject: Adopt to new packaging guidelines & other fixes Signed-off-by: Igor Gnatenko --- diff --git a/python-iniparse.spec b/python-iniparse.spec index 9d86ff0..b8f2092 100644 --- a/python-iniparse.spec +++ b/python-iniparse.spec @@ -1,35 +1,27 @@ -%global with_python3 1 +%global modname iniparse -%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} -%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}} +# Use the same directory of the main package for subpackage licence and docs +%global _docdir_fmt %{name} -Name: python-iniparse +%if 0%{?rhel} && 0%{?rhel} <= 7 +%bcond_with python3 +%else +%bcond_without python3 +%endif + +Name: python-%{modname} Version: 0.4 -Release: 18%{?dist} +Release: 19%{?dist} Summary: Python Module for Accessing and Modifying Configuration Data in INI files -Group: Development/Libraries License: MIT and Python URL: http://code.google.com/p/iniparse/ -Source0: http://iniparse.googlecode.com/files/iniparse-%{version}.tar.gz +Source0: http://iniparse.googlecode.com/files/%{modname}-%{version}.tar.gz Patch0: fix-issue-28.patch +%if %{with python3} # The patch upstream (http://code.google.com/p/iniparse/issues/detail?id=22) # is Python3-only. The patch below uses python-six to create a version that works # with both Python major versions and is more error-prone. Patch1: %{name}-python3-compat.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -BuildRequires: python-setuptools -BuildRequires: python-six -BuildRequires: python2-devel -BuildRequires: python-test - -Requires: python-six - -%if 0%{?with_python3} -BuildRequires: python3-setuptools -BuildRequires: python3-six -BuildRequires: python3-devel -BuildRequires: python3-test %endif BuildArch: noarch @@ -41,13 +33,31 @@ files (order of sections & options, indentation, comments, and blank lines are preserved when data is updated), and is more convenient to use. -%if 0%{?with_python3} -%package -n python3-iniparse +%package -n python2-%{modname} +Summary: Python 2 Module for Accessing and Modifying Configuration Data in INI files +%{?python_provide:%python_provide python2-%{modname}} +BuildRequires: python2-devel +BuildRequires: python2-six +BuildRequires: python-test +Requires: python2-six + +%description -n python2-%{modname} +iniparse is an INI parser for Python 2 which is API compatible +with the standard library's configparser, preserves structure of INI +files (order of sections & options, indentation, comments, and blank +lines are preserved when data is updated), and is more convenient to +use. + +%if %{with python3} +%package -n python3-%{modname} Summary: Python 3 Module for Accessing and Modifying Configuration Data in INI files -Group: Development/Libraries +%{?python_provide:%python_provide python3-%{modname}} +BuildRequires: python3-devel +BuildRequires: python3-six +BuildRequires: python3-test Requires: python3-six -%description -n python3-iniparse +%description -n python3-%{modname} iniparse is an INI parser for Python 3 which is API compatible with the standard library's configparser, preserves structure of INI files (order of sections & options, indentation, comments, and blank @@ -56,73 +66,53 @@ use. %endif %prep -%setup -q -n iniparse-%{version} +%setup -q -n %{modname}-%{version} %patch0 -p1 +%if %{with python3} %patch1 -p0 -chmod -c -x html/index.html - - -%if 0%{?with_python3} -rm -rf %{py3dir} -cp -a . %{py3dir} %endif +chmod -c -x html/index.html %build -%{__python2} setup.py build - -%if 0%{?with_python3} -pushd %{py3dir} -%{__python3} setup.py build -popd +%py2_build +%if %{with python3} +%py3_build %endif %install -rm -rf $RPM_BUILD_ROOT -%if 0%{?with_python3} -pushd %{py3dir} -%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT -mv $RPM_BUILD_ROOT/usr/share/doc/iniparse-%{version} $RPM_BUILD_ROOT/%{_docdir}/python3-iniparse -popd +%py2_install +%if %{with python3} +%py3_install %endif - - -%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT -mv $RPM_BUILD_ROOT/usr/share/doc/iniparse-%{version} $RPM_BUILD_ROOT%{_pkgdocdir} - -# Don't dupe the license -rm -rf $RPM_BUILD_ROOT%{_pkgdocdir}/LICENSE* -rm -rf $RPM_BUILD_ROOT%{_docdir}/python3-iniparse/LICENSE* - -%clean -rm -rf $RPM_BUILD_ROOT +rm -vfr %{buildroot}%{_docdir}/* %check %{__python2} runtests.py - -%if 0%{?with_python3} -pushd %{py3dir} +%if %{with python3} %{__python3} runtests.py -popd %endif -%files -%defattr(-,root,root,-) -%doc %{_pkgdocdir} -%{!?_licensedir:%global license %%doc} +%files -n python2-%{modname} %license LICENSE LICENSE-PSF -%{python_sitelib}/* +%doc README Changelog html/ +%{python2_sitelib}/%{modname}/ +%{python2_sitelib}/%{modname}-%{version}-*.egg-info -%if 0%{?with_python3} -%files -n python3-iniparse -%defattr(-,root,root,-) -%doc %{_docdir}/python3-iniparse -%{!?_licensedir:%global license %%doc} +%if %{with python3} +%files -n python3-%{modname} %license LICENSE LICENSE-PSF -%{python3_sitelib}/* +%doc README Changelog html/ +%{python3_sitelib}/%{modname}/ +%{python3_sitelib}/%{modname}-%{version}-*.egg-info %endif - %changelog +* Tue Apr 12 2016 Igor Gnatenko - 0.4-19 +- Make python3 builds conditionally +- Adopt to new packaging guidelines +- Remove setuptools from BRs as it's not needed +- Cleanup spec + * Thu Feb 04 2016 Fedora Release Engineering - 0.4-18 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild