Blob Blame History Raw
%if 0%{?el9}
# Needs pytest-xdist and typing-extensions which pull in a bunch of BRs, see
# missing-epel9-test-brs.json
%bcond_with tests
%bcond_with doc
%else
%bcond_without tests
%bcond_without doc
%endif

Name:           python-hypothesis
Version:        6.45.0
Release:        %autorelease
Summary:        Library for property based testing

License:        MPLv2.0
URL:            https://github.com/HypothesisWorks/hypothesis
Source0:        %{url}/archive/hypothesis-python-%{version}/hypothesis-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  pyproject-rpm-macros >= 0-43

%if %{with tests}
# optional test dependencies:
BuildRequires:  %{py3_dist typing_extensions}
%endif

%if %{with doc}
BuildRequires:  %{_bindir}/sphinx-build
BuildRequires:  %{py3_dist sphinx-hoverxref}
BuildRequires:  %{py3_dist sphinx-rtd-theme}
BuildRequires:  %{py3_dist sphinx_selective_exclude}
%endif


%global _description %{expand:
Hypothesis is a library for testing your Python code against a much
larger range of examples than you would ever want to write by
hand. It’s based on the Haskell library, Quickcheck, and is designed
to integrate seamlessly into your existing Python unit testing work
flow.}

%description %{_description}


%package     -n python%{python3_pkgversion}-hypothesis
Summary:        %{summary}

%description -n python%{python3_pkgversion}-hypothesis %{_description}


%global extras cli,ghostwriter,pytz,dateutil,lark,numpy,pandas,pytest,redis,zoneinfo,django
# extras with missing deps:
#  codemods: libcst
#  dpcontracts: dpcontracts
%{pyproject_extras_subpkg -n python%{python3_pkgversion}-hypothesis %{extras}}


%prep
%autosetup -n hypothesis-hypothesis-python-%{version}/hypothesis-python -p2
# disable Sphinx extensions that require Internet access
sed -i -e '/sphinx.ext.intersphinx/d' docs/conf.py
# disable Sphinx non-available extensions
sed -i -e '/sphinx_codeautolink/d' docs/conf.py


%generate_buildrequires
%pyproject_buildrequires %{?with_tests:../requirements/test.in -x %{extras}}


%build
%pyproject_wheel

%if %{with doc}
PYTHONPATH=src READTHEDOCS=True sphinx-build -b man docs docs/_build/man
%endif


%install
%pyproject_install
%pyproject_save_files hypothesis

%if %{with doc}
install -Dpm0644 -t %{buildroot}%{_mandir}/man1 docs/_build/man/hypothesis.1
%endif


%if %{with tests}
%check
k="not test_registered_from_entrypoint"

# https://github.com/HypothesisWorks/hypothesis/issues/3035
k="$k and not test_recursion_error_is_not_flaky"

# https://github.com/pandas-dev/pandas/commit/95a86a9884e
%if "%{_arch}" == "s390x"
k="$k and not test_data_frames_with_timestamp_columns"
%endif

%pytest -v -n auto -k "$k" \
  --ignore tests/codemods \
  --ignore tests/dpcontracts \
  --ignore tests/redis \

# The BRP that handles bytecompilation already run at the end of %%install.
# This autogenerated file gets re-generated during tests,
# the tests asserts the content is identical, but the mtime is changed anyway.
# Since %%pytest disables byte-compilation, we need to update the pycs manually:
%py_byte_compile %{python3} %{buildroot}%{python3_sitelib}/hypothesis/internal/conjecture/shrinking/learned_dfas.py
%endif


%files -n python%{python3_pkgversion}-hypothesis -f %{pyproject_files}
%license ../LICENSE.txt
%doc README.rst
%{python3_sitelib}/_hypothesis_pytestplugin.py
%{python3_sitelib}/__pycache__/_hypothesis_pytestplugin*.pyc
%{_bindir}/hypothesis
%if %{with doc}
%{_mandir}/man1/hypothesis.1*
%endif


%changelog
%autochangelog