Name:           python-zstd
Version:        1.5.7.3
Release:        1
Summary:        ZSTD Bindings for Python
License:        BSD-2-Clause
URL:            https://github.com/sergey-dryabzhinsky/python-zstd
Source0:        %{pypi_source zstd}
Patch0:         python-zstd-1.5.5.1-test-external.patch

%description
Simple Python bindings for the Zstd compression library.

%package -n     python3-zstd
Summary:        %{summary}
# Base build requires
BuildRequires:  gcc
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:	python3-cffi
BuildRequires:  pkgconfig(libzstd) >= 1.5.7
Requires:       zstd%{?_isa} >= %(rpm -q --queryformat="%%{VERSION}" zstd)

%description -n python3-zstd
Simple Python bindings for the Zstd compression library.

%package help
Summary:        ZSTD Bindings for Python
Provides:       python3-zstd-doc
Buildarch:      noarch
%description help
Simple Python bindings for the Zstd compression library.

%prep
%autosetup -n zstd-%{version} -p1
# Remove bundled egg-info
rm -rf src/%{pypi_name}.egg-info
# Remove bundled zstd library
rm -rf zstd/
# do not test the version matching, we don't really need exact version of
# zstd here
rm tests/test_version.py
sed -i -e '/tests\.test_version/d' setup.py
sed -i -e '/test_version/d' tests/__init__.py
# do not test the spped when building with external libs
rm tests/test_speed.py
sed -i -e '/tests\.test_speed/d' setup.py
sed -i -e '/test_speed/d' tests/__init__.py

%build
%py3_build -- --external

%install
%py3_install

%check
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \
%{__python3} -m unittest -v

%files -n python3-zstd
%license LICENSE
%{python3_sitearch}/zstd*

%files help
%doc README.rst

%changelog
* Fri Jan 09 2026 YangengLiu <dev01202@linx-info.com> - 1.5.7.3-1
- update version to 1.5.7.3
- Create context for compress one time
- Init cores cache as early as possible on module init

* Mon Jul 14 2025 Funda Wang <fundawang@yeah.net> - 1.5.7.2-1
- update to version 1.5.7.2
- build with system zstd
- fix test usage

* Fri Apr 07 2023 Ge Wang <wang__ge@126.com> - 1.5.5.1-1
- Update to version 1.5.5.1

* Mon Feb 27 2023 wubijie <wubijie@kylinos.cn> - 1.5.4.0-1
- Update package to version 1.5.4.0

* Fri Dec 09 2022 chendexi <chendexi@kylinos.cn> - 1.5.2.6-1
- Upgrade package to version 1.5.2.6

* Wed Aug 10 2022 liqiuyu <liqiuyu@kylinos.cn> - 1.5.2.5-1
- update to 1.5.2.5

* Fri Jun 03 2022 OpenStack_SIG <openstack@openeuler.org> - 1.5.1.0-1
- Upgrade python3-zstd to version 1.5.1.0

* Tue May 10 2022 yangping <yangping69@h-partners> - 1.4.8.1-3
- License compliance rectification

* Sat May 07 2022 wulei <wulei80@h-partners.com> 1.4.8.1-2
- Fix python3.8+ use py_ssize_t type

* Tue Feb 23 2021 wangxiyuan <wangxiyuan1007@gmail.com>
- Package Spec Init