Blob Blame Raw
%global srcname zope.testrunner
%global pkgname zope-testrunner

# 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

Name:           python-%{pkgname}
Version:        5.0
Release:        1%{?dist}
Summary:        Zope testrunner script

License:        ZPLv2.1
URL:            https://pypi.python.org/pypi/%{srcname}
Source0:        https://github.com/zopefoundation/%{srcname}/archive/%{version}/%{srcname}-%{version}.tar.gz
BuildArch:      noarch

BuildRequires:  help2man

BuildRequires:  python2-devel
BuildRequires:  python2dist(python-subunit)
BuildRequires:  python2dist(setuptools)
BuildRequires:  python2dist(six)
BuildRequires:  python2dist(testtools)
BuildRequires:  python2dist(zope.exceptions)
BuildRequires:  python2dist(zope.interface)
BuildRequires:  python2dist(zope.testing)

BuildRequires:  python3-devel
BuildRequires:  python3dist(python-subunit)
BuildRequires:  python3dist(setuptools)
BuildRequires:  python3dist(six)
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3dist(sphinxcontrib-programoutput)
BuildRequires:  python3dist(testtools)
BuildRequires:  python3dist(zope.exceptions)
BuildRequires:  python3dist(zope.interface)
BuildRequires:  python3dist(zope.testing)

%description
This package provides a flexible test runner with layer support.

%package     -n python2-%{pkgname}
Summary:        Zope testrunner script
Requires:       python2dist(six)
Requires:       python2dist(zope.exceptions)
Requires:       python2dist(zope.interface)
Requires:       python2dist(zope.testing)

%{?python_provide:%python_provide python2-%{pkgname}}

%description -n python2-%{pkgname}
This package provides a flexible test runner with layer support.

%package     -n python3-%{pkgname}
Summary:        Zope testrunner script
Requires:       python3dist(six)
Requires:       python3dist(zope.exceptions)
Requires:       python3dist(zope.interface)
Requires:       python3dist(zope.testing)

%{?python_provide:%python_provide python3-%{pkgname}}

%description -n python3-%{pkgname}
This package provides a flexible test runner with layer support.

%prep
%setup -qc
mv %{srcname}-%{version} python2
if [ ! -e python2/src/zope/testrunner/tests/testrunner-ex/__init__.py ]; then
  touch python2/src/zope/testrunner/tests/testrunner-ex/__init__.py
fi

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

# Prepare to build for both python2 and python3
cp -a python2 python3

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

%build
pushd python2
%py2_build
popd

pushd python3
%py3_build
popd

%install
pushd python2
%py2_install
mv %{buildroot}%{_bindir}/zope-testrunner %{buildroot}%{_bindir}/zope-testrunner-%{python2_version}
popd

pushd python3
%py3_install
mv %{buildroot}%{_bindir}/zope-testrunner %{buildroot}%{_bindir}/zope-testrunner-%{python3_version}
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-%{python3_version}

cp %{buildroot}%{_mandir}/man1/zope-testrunner{,-2}.1

# 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
fi
mkdir include
cp -a %{_includedir}/python%{python3_version}* include
cp -a %{buildroot}%{python3_sitelib}/zope* \
      lib/python%{python3_version}/site-packages
export PYTHONHOME=$PWD:$PWD
sphinx-build-3 -b html -d docs/_build/doctrees docs docs/_build/html
rm -fr include lib lib64
rm -f docs/_build/html/.buildinfo
unset PYTHONHOME
popd

# Symlinks for executables
ln -s ./zope-testrunner-%{python2_version} %{buildroot}%{_bindir}/zope-testrunner-2
ln -s ./zope-testrunner-%{python3_version} %{buildroot}%{_bindir}/zope-testrunner-3
ln -s ./zope-testrunner-3 %{buildroot}%{_bindir}/zope-testrunner

%check
pushd python3
# The tests don't work 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
fi
mkdir include
cp -a %{_includedir}/python%{python3_version}* include
cp -a %{buildroot}%{python3_sitelib}/zope* \
      lib/python%{python3_version}/site-packages
export PYTHONHOME=$PWD:$PWD
%{__python3} setup.py test
rm -fr include lib lib64
unset PYTHONHOME
popd

%files -n python2-%{pkgname}
%doc python2/CHANGES.rst python2/README.rst python3/docs/_build/html
%license python2/COPYRIGHT.rst python2/LICENSE.rst
%{_bindir}/zope-testrunner-2*
%{_mandir}/man1/zope-testrunner-2.1*
%{python2_sitelib}/%{srcname}*
%{python2_sitelib}/zope/testrunner/
%exclude %{python2_sitelib}/zope/testrunner/tests

%files -n python3-%{pkgname}
%doc python3/CHANGES.rst python3/README.rst python3/docs/_build/html
%license python3/COPYRIGHT.rst python3/LICENSE.rst
%{_bindir}/zope-testrunner
%{_bindir}/zope-testrunner-3*
%{_mandir}/man1/zope-testrunner.1*
%{python3_sitelib}/%{srcname}*
%{python3_sitelib}/zope/testrunner/
%exclude %{python3_sitelib}/zope/testrunner/tests

%changelog
* Tue Mar 19 2019 Jerry James <loganjerry@gmail.com> - 5.0-1
- New upstream version

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.9.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Mon Nov 26 2018 Jerry James <loganjerry@gmail.com> - 4.9.2-1
- New upstream version

* Mon Nov 26 2018 Lumír Balhar <lbalhar@redhat.com> - 4.9-2
- Fix issue with automatic dependencies and executables' names

* Sat Nov 17 2018 Jerry James <loganjerry@gmail.com> - 4.9-1
- New upstream version
- Do not ship the tests

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.8.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 4.8.1-3
- Rebuilt for Python 3.7

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.8.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Sun Nov 12 2017 Jerry James <loganjerry@gmail.com> - 4.8.1-1
- New upstream version

* Sat Nov 11 2017 Jerry James <loganjerry@gmail.com> - 4.8.0-1
- New upstream version

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 4.7.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Tue May 30 2017 Jerry James <loganjerry@gmail.com> - 4.7.0-1
- New upstream version
- subunit is no longer a dependency
- Enable python 3 tests

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 4.6.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Wed Dec 28 2016 Jerry James <loganjerry@gmail.com> - 4.6.0-1
- New upstream version
- Drop upstreamed test patch

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 4.5.1-4
- Rebuild for Python 3.6

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.5.1-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Tue Jun 21 2016 Jerry James <loganjerry@gmail.com> - 4.5.1-2
- Fix spurious build failures due to use of _libdir in a noarch package

* Mon Jun 20 2016 Jerry James <loganjerry@gmail.com> - 4.5.1-1
- New upstream version

* Wed Jun  8 2016 Jerry James <loganjerry@gmail.com> - 4.5.0-3
- Do not test with detox; it downloads files at build time

* Wed Jun  1 2016 Jerry James <loganjerry@gmail.com> - 4.5.0-2
- Fix directory ownership
- Add man page

* Wed Jun  1 2016 Jerry James <loganjerry@gmail.com> - 4.5.0-1
- Initial RPM