Adopt to new packaging guidelines & other fixes

Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
This commit is contained in:
Igor Gnatenko 2016-04-12 11:57:36 +02:00
parent 416ba6dfd4
commit 874e4fdb5b

View File

@ -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()")} # Use the same directory of the main package for subpackage licence and docs
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}} %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 Version: 0.4
Release: 18%{?dist} Release: 19%{?dist}
Summary: Python Module for Accessing and Modifying Configuration Data in INI files Summary: Python Module for Accessing and Modifying Configuration Data in INI files
Group: Development/Libraries
License: MIT and Python License: MIT and Python
URL: http://code.google.com/p/iniparse/ 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 Patch0: fix-issue-28.patch
%if %{with python3}
# The patch upstream (http://code.google.com/p/iniparse/issues/detail?id=22) # 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 # 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. # with both Python major versions and is more error-prone.
Patch1: %{name}-python3-compat.patch 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 %endif
BuildArch: noarch 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 lines are preserved when data is updated), and is more convenient to
use. use.
%if 0%{?with_python3} %package -n python2-%{modname}
%package -n python3-iniparse 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 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 Requires: python3-six
%description -n python3-iniparse %description -n python3-%{modname}
iniparse is an INI parser for Python 3 which is API compatible iniparse is an INI parser for Python 3 which is API compatible
with the standard library's configparser, preserves structure of INI with the standard library's configparser, preserves structure of INI
files (order of sections & options, indentation, comments, and blank files (order of sections & options, indentation, comments, and blank
@ -56,73 +66,53 @@ use.
%endif %endif
%prep %prep
%setup -q -n iniparse-%{version} %setup -q -n %{modname}-%{version}
%patch0 -p1 %patch0 -p1
%if %{with python3}
%patch1 -p0 %patch1 -p0
%endif
chmod -c -x html/index.html chmod -c -x html/index.html
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif
%build %build
%{__python2} setup.py build %py2_build
%if %{with python3}
%if 0%{?with_python3} %py3_build
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif %endif
%install %install
rm -rf $RPM_BUILD_ROOT %py2_install
%if 0%{?with_python3} %if %{with python3}
pushd %{py3dir} %py3_install
%{__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
%endif %endif
rm -vfr %{buildroot}%{_docdir}/*
%{__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
%check %check
%{__python2} runtests.py %{__python2} runtests.py
%if %{with python3}
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} runtests.py %{__python3} runtests.py
popd
%endif %endif
%files %files -n python2-%{modname}
%defattr(-,root,root,-)
%doc %{_pkgdocdir}
%{!?_licensedir:%global license %%doc}
%license LICENSE LICENSE-PSF %license LICENSE LICENSE-PSF
%{python_sitelib}/* %doc README Changelog html/
%{python2_sitelib}/%{modname}/
%{python2_sitelib}/%{modname}-%{version}-*.egg-info
%if 0%{?with_python3} %if %{with python3}
%files -n python3-iniparse %files -n python3-%{modname}
%defattr(-,root,root,-)
%doc %{_docdir}/python3-iniparse
%{!?_licensedir:%global license %%doc}
%license LICENSE LICENSE-PSF %license LICENSE LICENSE-PSF
%{python3_sitelib}/* %doc README Changelog html/
%{python3_sitelib}/%{modname}/
%{python3_sitelib}/%{modname}-%{version}-*.egg-info
%endif %endif
%changelog %changelog
* Tue Apr 12 2016 Igor Gnatenko <ignatenko@redhat.com> - 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 <releng@fedoraproject.org> - 0.4-18 * Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.4-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild