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 srcname olefile
%global _description \ %global _description %{expand:
olefile is a Python package to parse, read and write Microsoft OLE2 files\ olefile is a Python package to parse, read and write Microsoft OLE2 files
(also called Structured Storage, Compound File Binary Format or Compound\ (also called Structured Storage, Compound File Binary Format or Compound
Document File Format), such as Microsoft Office 97-2003 documents,\ Document File Format), such as Microsoft Office 97-2003 documents,
vbaProject.bin in MS Office 2007+ files, Image Composer and FlashPix files,\ vbaProject.bin in MS Office 2007+ files, Image Composer and FlashPix files,
Outlook messages, StickyNotes, several Microscopy file formats, McAfee\ Outlook messages, StickyNotes, several Microscopy file formats, McAfee
antivirus quarantine files, etc. 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 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 Source0: https://files.pythonhosted.org/packages/source/o/%{srcname}/%{srcname}-%{version}.zip
BuildArch: noarch BuildArch: noarch
BuildRequires: dos2unix
BuildRequires: /usr/bin/find
%description %{_description} %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} %package -n python2-%{srcname}
Summary: %{summary} Summary: %{summary}
BuildRequires: python2-devel BuildRequires: python2-devel
BuildRequires: python2-setuptools 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}} %{?python_provide:%python_provide python2-%{srcname}}
%description -n python2-%{srcname} %{_description} %description -n python2-%{srcname} %{_description}
Python2 version. Python2 version.
%endif %endif
%if 0%{?with_python3}
%package -n python%{python3_pkgversion}-%{srcname} %package -n python%{python3_pkgversion}-%{srcname}
Summary: %{summary} Summary: %{summary}
BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: python%{python3_pkgversion}-setuptools
# There is no python34-sphinx package in EPEL 7 #BuildRequires: python%%{python3_pkgversion}-sphinx_rtd_theme
%if 0%{?fedora} || 0%{?rhel} >= 8
BuildRequires: python%{python3_pkgversion}-sphinx
BuildRequires: python%{python3_pkgversion}-sphinx_rtd_theme
%endif
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}} %{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}
%description -n python%{python3_pkgversion}-%{srcname} %{_description} %description -n python%{python3_pkgversion}-%{srcname} %{_description}
Python3 version. Python3 version.
%endif
%prep %prep
%autosetup -p1 -n %{srcname}-%{version} %autosetup -p1 -n %{srcname}-%{version}
# Fix windows EOL
find ./ -type f -name '*.py' -exec dos2unix '{}' ';'
dos2unix doc/*.rst
%build %build
%if 0%{?fedora} || 0%{?rhel} == 7 %if 0%{?with_python2}
%py2_build %py2_build
%if 0%{?fedora} && 0%{?fedora} < 31
make -C doc html BUILDDIR=_build_py2 SPHINXBUILD=sphinx-build-%python2_version
%endif
%endif %endif
%if 0%{?with_python3}
%py3_build %py3_build
%if 0%{?fedora} || 0%{?rhel} >= 8
make -C doc html BUILDDIR=_build_py3 SPHINXBUILD=sphinx-build-%python3_version
%endif %endif
make -C doc html BUILDDIR=_doc_build SPHINXBUILD=sphinx-build-%{python3_version}
%install %install
%if 0%{?fedora} || 0%{?rhel} == 7 %if 0%{?with_python2}
%py2_install %py2_install
%endif %endif
%if 0%{?with_python3}
%py3_install %py3_install
%endif
%check %check
# Tests got left out in the 0.44 source archive # Tests got left out in the 0.44 source archive
# https://github.com/decalage2/olefile/issues/56 # https://github.com/decalage2/olefile/issues/56
# PYTHONPATH=%%{buildroot}%%{python2_sitelib} %%{__python2} tests/test_olefile.py %if 0%{?with_python2}
# PYTHONPATH=%%{buildroot}%%{python3_sitelib} %%{__python3} tests/test_olefile.py 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} %files -n python2-%{srcname}
%doc README.md %doc README.md
%if 0%{?fedora} && 0%{?fedora} < 31
%doc doc/_build_py2/html
%endif
%license doc/License.rst %license doc/License.rst
%{python2_sitelib}/olefile-*.egg-info %{python2_sitelib}/olefile-*.egg-info
%{python2_sitelib}/olefile/ %{python2_sitelib}/olefile/
%endif %endif
%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-%{srcname} %files -n python%{python3_pkgversion}-%{srcname}
%doc README.md %doc README.md
%if 0%{?fedora} || 0%{?rhel} >= 8
%doc doc/_build_py3/html
%endif
%license doc/License.rst %license doc/License.rst
%{python3_sitelib}/olefile-*.egg-info %{python3_sitelib}/olefile-*.egg-info
%{python3_sitelib}/olefile/ %{python3_sitelib}/olefile/
%endif
%changelog %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 * Mon Oct 07 2019 Sandro Mani <manisandro@gmail.com> - 0.46-7
- BR: python-setuptools (#1758972) - BR: python-setuptools (#1758972)

Loading…
Cancel
Save