Blame SPECS/python3.11-pytest.spec

80c745
%global __python3 /usr/bin/python3.11
80c745
%global python3_pkgversion 3.11
80c745
80c745
%global pkgname pytest
80c745
80c745
Name:           python%{python3_pkgversion}-pytest
80c745
%global base_version 7.2.0
80c745
#global prerelease ...
80c745
Version:        %{base_version}%{?prerelease:~%{prerelease}}
80c745
Release:        1%{?dist}
80c745
Summary:        Simple powerful testing with Python
80c745
License:        MIT
80c745
URL:            https://pytest.org
80c745
# see https://github.com/pytest-dev/pytest/issues/10042#issuecomment-1237132867
80c745
Patch:          pytest-7.1.3-fix-xfails.patch
80c745
Source0:        %{pypi_source pytest %{base_version}%{?prerelease}}
80c745
80c745
# RHEL: Disabled due to missing dependencies
80c745
%bcond_with tests
80c745
80c745
# Only disabling the optional tests is a more complex but careful approach
80c745
# Pytest will skip the related tests, so we only conditionalize the BRs
80c745
# This bcond is ignored when tests are disabled
80c745
%bcond_without optional_tests
80c745
80c745
# To run the tests in %%check we use pytest-timeout
80c745
# When building pytest for the first time with new Python version
80c745
# that is not possible as it depends on pytest
80c745
# The bcond is ignored when tests are disabled
80c745
%bcond_without timeout
80c745
80c745
BuildRequires:  python%{python3_pkgversion}-devel
80c745
BuildRequires:  python%{python3_pkgversion}-rpm-macros
80c745
BuildRequires:  python%{python3_pkgversion}-setuptools
80c745
80c745
# Those are also runtime deps, needed for tests
80c745
# We keep them unconditionally, so we don't accidentally build pytest
80c745
# before them and get broken dependencies
80c745
BuildRequires:  python%{python3_pkgversion}-attrs >= 19.2
80c745
BuildRequires:  python%{python3_pkgversion}-packaging
80c745
BuildRequires:  python%{python3_pkgversion}-iniconfig
80c745
BuildRequires:  python%{python3_pkgversion}-pluggy >= 0.12
80c745
80c745
Requires:  python%{python3_pkgversion}dist(attrs) >= 19.2
80c745
Requires:  python%{python3_pkgversion}dist(packaging)
80c745
Requires:  python%{python3_pkgversion}dist(iniconfig)
80c745
Requires:  python%{python3_pkgversion}dist(pluggy) >= 0.12
80c745
80c745
%if %{with tests}
80c745
BuildRequires:  python%{python3_pkgversion}-hypothesis >= 3.56
80c745
BuildRequires:  python%{python3_pkgversion}-pygments >= 2.7.2
80c745
BuildRequires:  python%{python3_pkgversion}-xmlschema
80c745
%if %{with optional_tests}
80c745
BuildRequires:  python%{python3_pkgversion}-argcomplete
80c745
#BuildRequires:  python%{python3_pkgversion}-asynctest -- not packaged in Fedora
80c745
BuildRequires:  python%{python3_pkgversion}-decorator
80c745
BuildRequires:  python%{python3_pkgversion}-jinja2
80c745
BuildRequires:  python%{python3_pkgversion}-mock
80c745
BuildRequires:  python%{python3_pkgversion}-nose
80c745
BuildRequires:  python%{python3_pkgversion}-numpy
80c745
BuildRequires:  python%{python3_pkgversion}-pexpect
80c745
BuildRequires:  python%{python3_pkgversion}-pytest-xdist
80c745
BuildRequires:  python%{python3_pkgversion}-twisted
80c745
BuildRequires:  /usr/bin/lsof
80c745
%endif
80c745
%if %{with timeout}
80c745
BuildRequires:  python%{python3_pkgversion}-pytest-timeout
80c745
%endif
80c745
%endif
80c745
80c745
BuildRequires:  %{_bindir}/rst2html
80c745
80c745
BuildArch:      noarch
80c745
80c745
%description
80c745
The pytest framework makes it easy to write small tests, yet scales to support
80c745
complex functional testing for applications and libraries.
80c745
80c745
%prep
80c745
%autosetup -p1 -n %{pkgname}-%{base_version}%{?prerelease}
80c745
80c745
80c745
# remove setuptools_scm dependency since we don't have it in RHEL
80c745
sed -i '/setuptools-scm/d' setup.cfg
80c745
80c745
# since setuptools_scm is not available we need to sed out it's usage from setup.py and set the correct version
80c745
sed -i 's/setup()/setup(version="%{version}")/g' setup.py
80c745
80c745
80c745
80c745
80c745
%build
80c745
%py3_build
80c745
80c745
for f in README CHANGELOG CONTRIBUTING ; do
80c745
  rst2html ${f}.rst > ${f}.html
80c745
done
80c745
80c745
%install
80c745
%py3_install
80c745
mv %{buildroot}%{_bindir}/pytest %{buildroot}%{_bindir}/pytest-%{python3_version}
80c745
mv %{buildroot}%{_bindir}/py.test %{buildroot}%{_bindir}/py.test-%{python3_version}
80c745
80c745
80c745
# remove shebangs from all scripts
80c745
find %{buildroot}%{python3_sitelib} \
80c745
     -name '*.py' \
80c745
     -exec sed -i -e '1{/^#!/d}' {} \;
80c745
80c745
%if %{with tests}
80c745
%check
80c745
%global __pytest %{buildroot}%{_bindir}/pytest
80c745
# optional_tests deps contain pytest-xdist, so we can use it to run tests faster
80c745
%pytest testing %{?with_timeout:--timeout=30} %{?with_optional_tests:-n auto} -rs
80c745
%endif
80c745
export PYTHONPATH=%{buildroot}%{python3_sitelib}
80c745
test "$(%{python3} -c 'import pytest; print(pytest.__version__)')" == "%{version}"
80c745
80c745
%files -n python%{python3_pkgversion}-%{pkgname}
80c745
%doc CHANGELOG.html
80c745
%doc README.html
80c745
%doc CONTRIBUTING.html
80c745
%license LICENSE
80c745
%{_bindir}/pytest-%{python3_version}
80c745
%{_bindir}/py.test-%{python3_version}
80c745
%{python3_sitelib}/pytest-*.egg-info/
80c745
%{python3_sitelib}/_pytest/
80c745
%{python3_sitelib}/pytest/
80c745
%pycached %{python3_sitelib}/py.py
80c745
80c745
%changelog
80c745
* Wed Oct 19 2022 Charalampos Stratakis <cstratak@redhat.com> - 7.2.0-1
80c745
- Initial package
80c745
- Fedora contributions by:
80c745
      Charalampos Stratakis <cstratak@redhat.com>
80c745
      David Malcolm <dmalcolm@redhat.com>
80c745
      Dennis Gilmore <dennis@ausil.us>
80c745
      Gwyn Ciesla <limburgher@gmail.com>
80c745
      Igor Gnatenko <ignatenkobrain@fedoraproject.org>
80c745
      Lumir Balhar <lbalhar@redhat.com>
80c745
      Miro HronĨok <miro@hroncok.cz>
80c745
      Nils Philippsen <nils@redhat.com>
80c745
      Orion Poplawski <orion@cora.nwra.com>
80c745
      Peter Robinson <pbrobinson@gmail.com>
80c745
      Petr Viktorin <pviktori@redhat.com>
80c745
      Richard Shaw <hobbes1069@gmail.com>
80c745
      Robert Kuska <rkuska@redhat.com>
80c745
      Thomas Moschny <thm@fedoraproject.org>