File python-pyppmd.spec of Package python-pyppmd

#
# spec file for package python-pyppmd
#
# Copyright (c) 2026 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%{?sle15_python_module_pythons}
Name:           python-pyppmd
Version:        1.3.1
Release:        0
Summary:        PPMd compression/decompression library
License:        LGPL-2.1-or-later
URL:            https://github.com/miurahr/pyppmd
Source:         https://files.pythonhosted.org/packages/source/p/pyppmd/pyppmd-%{version}.tar.gz
BuildRequires:  %{python_module base >= 3.10}
BuildRequires:  %{python_module devel >= 3.10}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module setuptools_scm >= 6.0.1}
BuildRequires:  %{python_module wheel}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
# SECTION test
BuildRequires:  %{python_module coverage}
BuildRequires:  %{python_module cffi}
BuildRequires:  %{python_module hypothesis}
BuildRequires:  %{python_module py-cpuinfo}
BuildRequires:  %{python_module pytest >= 6}
BuildRequires:  %{python_module pytest-benchmark}
BuildRequires:  %{python_module pytest-cov}
BuildRequires:  %{python_module pytest-timeout}
BuildRequires:  %{python_module readme_renderer}
# /SECTION
%python_subpackages

%description
The pyppmd module provides classes and functions for compressing and
decompressing text data, using PPM(Prediction by partial matching)
compression algorithm which has several variations of implementations.
PPMd is the implementation by Dmitry Shkarin. PyPPMD use Igor Pavlov's
range coder introduced in 7-zip.

The API is similar to Python's bz2/lzma/zlib module.

Some parts of th codes are derived from 7-zip, pyzstd and ppmd-cffi.

%prep
%setup -q -n pyppmd-%{version}
# increase test deadline for slow obs executions (e.g. on s390x)
echo "

import hypothesis
hypothesis.settings.register_profile(
    'obs',
    deadline=5000,
    suppress_health_check=[hypothesis.HealthCheck.too_slow]
)
" >> tests/conftest.py
sed -i 's/milliseconds=300/milliseconds=5000/g' tests/test_fuzzer.py

%build
# Flags are present in the BE anyway. An additonal export CFLAGS makes
# test test_ppmd7_decode_chunks crash with
# Fatal Python error: Aborted (core dumped).
# export CFLAGS="%%{optflags}"
%pyproject_wheel

%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}

%check
# List of tests to disable
# - test_ppmd7_decode_chunks hangs indefinitely due to missing
#   python-pkg in oS, gives
#   Fatal Python error: Aborted (core dumped) when killed
%pytest_arch --hypothesis-profile=obs -v --tb=short -k "not test_ppmd8"
%pytest_arch --hypothesis-profile=obs -v --tb=short tests/test_ppmd8.py
# tests/test_ppmd8.py

%files %{python_files}
%doc Changelog.rst README.rst
%license LICENSE
%{python_sitearch}/pyppmd
%{python_sitearch}/pyppmd-%{version}.dist-info

%changelog
openSUSE Build Service is sponsored by