Blame SPECS/python3.11-pytest.spec

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