Blob Blame History Raw
# We have source files with intentional syntax errors, in order to test.
# Do not fail the build just because some file is not valid python.
%undefine _python_bytecompile_errors_terminate_build

%global _docdir_fmt python3-zope-testrunner

Name:           python-zope-testrunner
Version:        6.4
Release:        %autorelease
Summary:        Zope testrunner script

License:        ZPL-2.1
Source0:        %{vcs}/archive/%{version}/zope.testrunner-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  help2man
BuildRequires:  python3-devel
BuildRequires:  python3-docs
BuildRequires:  %{py3_dist manuel}

This package provides a flexible test runner with layer support.

%package     -n python3-zope-testrunner
Summary:        Zope testrunner script

%description -n python3-zope-testrunner
This package provides a flexible test runner with layer support.

%package        doc
# The content is ZPL-2.1.  Files added by Sphinx have the following licences:
# searchindex.js: BSD-2-Clause
# _static/*: BSD-2-Clause, except for the following:
# _static/jquery*.js: MIT
# _static/underscore*.js: MIT
License:        ZPL-2.1 AND BSD-2-Clause AND MIT
Summary:        Documentation for zope.testrunner

%description    doc
Documentation for zope.testrunner.

%pyproject_extras_subpkg -n python3-zope-testrunner subunit

%autosetup -n zope.testrunner-%{version} -p1

# Update the sphinx HTML theme name
sed -i "s/'default'/'classic'/" docs/

# Fix the way python is invoked
sed -i 's/python -m/python3 -m/' docs/cli.rst

# Use local objects.inv for intersphinx
sed -i "s|\('https://docs\.python\.org/': \)None|\1'%{_docdir}/python3-docs/html/objects.inv'|" docs/

# Replace a deprecated directive
sed -i "s/autodoc_default_flags.*/autodoc_default_options = {'members': True, 'show-inheritance': True}/" docs/

%pyproject_buildrequires -t -x test,subunit,docs


rst2html --no-datestamp CHANGES.rst CHANGES.html
rst2html --no-datestamp README.rst README.html

# Not really RST:

mkdir -p %{buildroot}%{_mandir}/man1
PYTHONPATH=%{buildroot}%{python3_sitelib} \
help2man -s 1 -o %{buildroot}%{_mandir}/man1/zope-testrunner.1 \
  -N -n "Zope testrunner script" %{buildroot}%{_bindir}/zope-testrunner

# The Sphinx documentation cannot be built with an uninstalled zope.testrunner
# because python finds the installed zope package, which doesn't contain
# testrunner.  We fake out python by copying the entire installed tree to a
# local directory and adding this package inside the zope directory.
mkdir lib
cp -a %{_prefix}/lib/python%{python3_version} lib
if [ -d %{_prefix}/lib64/python%{python3_version} ]; then
  mkdir lib64
  cp -a %{_prefix}/lib64/python%{python3_version} lib64
mkdir include
cp -a %{_includedir}/python%{python3_version}* include
cp -a %{buildroot}%{python3_sitelib}/zope* \
sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
rm -fr include lib lib64
rm -f docs/_build/html/.buildinfo


%files -n python3-zope-testrunner
%doc CHANGES.html README.html
%license COPYRIGHT
%exclude %{python3_sitelib}/zope/testrunner/tests

%files doc
%doc docs/_build/html