split doc to separate subpackage

conditional build for py2/py3 subpackages
epel9
rpmbuild 5 years ago
parent 0a05efe7e2
commit 6e16aa5bf7

@ -1,114 +1,155 @@
Name: python-olefile
Version: 0.46
Release: 8%{?dist}
Summary: Python package to parse, read and write Microsoft OLE2 files
%global srcname olefile
%global _description \
olefile is a Python package to parse, read and write Microsoft OLE2 files\
(also called Structured Storage, Compound File Binary Format or Compound\
Document File Format), such as Microsoft Office 97-2003 documents,\
vbaProject.bin in MS Office 2007+ files, Image Composer and FlashPix files,\
Outlook messages, StickyNotes, several Microscopy file formats, McAfee\
%global _description %{expand:
olefile is a Python package to parse, read and write Microsoft OLE2 files
(also called Structured Storage, Compound File Binary Format or Compound
Document File Format), such as Microsoft Office 97-2003 documents,
vbaProject.bin in MS Office 2007+ files, Image Composer and FlashPix files,
Outlook messages, StickyNotes, several Microscopy file formats, McAfee
antivirus quarantine files, etc.
}
# Build with python3 package by default
%bcond_without python3
# Build without python2 package for newer releases > fc32 and > rhel8
# python2 package already released for rhel8
# https://pagure.io/fesco/issue/2266
%if (0%{?fedora} && 0%{?fedora} > 32 ) || ( 0%{?rhel} && 0%{?rhel} > 8 )
%bcond_with python2
%else
%bcond_without python2
%endif
Name: python-%{srcname}
Version: 0.46
Release: 7%{?dist}
Summary: Python package to parse, read and write Microsoft OLE2 files
License: BSD
URL: https://pypi.python.org/pypi/olefile/
URL: https://www.decalage.info/python/olefile
# https://pypi.python.org/pypi/olefile/
# https://github.com/decalage2/olefile/releases
Source0: https://files.pythonhosted.org/packages/source/o/%{srcname}/%{srcname}-%{version}.zip
BuildArch: noarch
BuildRequires: dos2unix
BuildRequires: /usr/bin/find
%description %{_description}
%package doc
Summary: %{summary}
BuildArch: noarch
# Fedora >= 31 does not have python2-sphinx anymore.
# There is python-sphinx in RHEL 7, but it's possibly too old.
# Python26 sphinx works
BuildRequires: python%{python3_pkgversion}-sphinx
BuildRequires: python%{python3_pkgversion}-sphinx_rtd_theme
%description doc %{_description}
This package contains documentation for %{name}.
%if 0%{?fedora} || 0%{?rhel} == 7
%if 0%{?with_python2}
%package -n python2-%{srcname}
Summary: %{summary}
BuildRequires: python2-devel
BuildRequires: python2-setuptools
# There is python-sphinx in RHEL 7, but it's too old. Fedora >= 31 does not have python2-sphinx anymore.
%if 0%{?fedora} && 0%{?fedora} < 31
BuildRequires: python2-sphinx
%endif
%{?python_provide:%python_provide python2-%{srcname}}
%description -n python2-%{srcname} %{_description}
Python2 version.
%endif
%if 0%{?with_python3}
%package -n python%{python3_pkgversion}-%{srcname}
Summary: %{summary}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
# There is no python34-sphinx package in EPEL 7
%if 0%{?fedora} || 0%{?rhel} >= 8
BuildRequires: python%{python3_pkgversion}-sphinx
BuildRequires: python%{python3_pkgversion}-sphinx_rtd_theme
%endif
#BuildRequires: python%%{python3_pkgversion}-sphinx_rtd_theme
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}
%description -n python%{python3_pkgversion}-%{srcname} %{_description}
Python3 version.
%endif
%prep
%autosetup -p1 -n %{srcname}-%{version}
# Fix windows EOL
find ./ -type f -name '*.py' -exec dos2unix '{}' ';'
dos2unix doc/*.rst
%build
%if 0%{?fedora} || 0%{?rhel} == 7
%if 0%{?with_python2}
%py2_build
%if 0%{?fedora} && 0%{?fedora} < 31
make -C doc html BUILDDIR=_build_py2 SPHINXBUILD=sphinx-build-%python2_version
%endif
%endif
%if 0%{?with_python3}
%py3_build
%if 0%{?fedora} || 0%{?rhel} >= 8
make -C doc html BUILDDIR=_build_py3 SPHINXBUILD=sphinx-build-%python3_version
%endif
make -C doc html BUILDDIR=_doc_build SPHINXBUILD=sphinx-build-%{python3_version}
%install
%if 0%{?fedora} || 0%{?rhel} == 7
%if 0%{?with_python2}
%py2_install
%endif
%if 0%{?with_python3}
%py3_install
%endif
%check
# Tests got left out in the 0.44 source archive
# https://github.com/decalage2/olefile/issues/56
# PYTHONPATH=%%{buildroot}%%{python2_sitelib} %%{__python2} tests/test_olefile.py
# PYTHONPATH=%%{buildroot}%%{python3_sitelib} %%{__python3} tests/test_olefile.py
%if 0%{?with_python2}
PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} tests/test_olefile.py
%endif
%if 0%{?with_python3}
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} tests/test_olefile.py
%endif
%files doc
%doc doc/_doc_build/html
%if 0%{?fedora} || 0%{?rhel} == 7
%if 0%{?with_python2}
%files -n python2-%{srcname}
%doc README.md
%if 0%{?fedora} && 0%{?fedora} < 31
%doc doc/_build_py2/html
%endif
%license doc/License.rst
%{python2_sitelib}/olefile-*.egg-info
%{python2_sitelib}/olefile/
%endif
%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-%{srcname}
%doc README.md
%if 0%{?fedora} || 0%{?rhel} >= 8
%doc doc/_build_py3/html
%endif
%license doc/License.rst
%{python3_sitelib}/olefile-*.egg-info
%{python3_sitelib}/olefile/
%endif
%changelog
* Fri Nov 08 2019 Michal Ambroz <rebus AT_ seznam.cz> - 0.46-8
- rebuild for new version of oletools
- conditional stop building python2 subpackage on fc>32 and rhel>8
- split doc to separate subpackage
* Mon Oct 07 2019 Sandro Mani <manisandro@gmail.com> - 0.46-7
- BR: python-setuptools (#1758972)

Loading…
Cancel
Save