Accepting request 1066418 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/1066418
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-zstandard?expand=0&rev=9
This commit is contained in:
Dominique Leuenberger 2023-02-19 17:18:31 +00:00 committed by Git OBS Bridge
commit cb17627a77
3 changed files with 70 additions and 2 deletions

58
feature-detection.patch Normal file
View File

@ -0,0 +1,58 @@
diff --git a/c-ext/backend_c.c b/c-ext/backend_c.c
index e31dd15..a5d9dee 100644
--- a/c-ext/backend_c.c
+++ b/c-ext/backend_c.c
@@ -210,6 +210,20 @@ void zstd_module_init(PyObject *m) {
Py_DECREF(feature);
#endif
+#ifdef SYSTEM_ZSTD
+ feature = PyUnicode_FromString("system_zstd");
+ if (NULL == feature) {
+ PyErr_SetString(PyExc_ImportError, "could not create feature string");
+ return;
+ }
+
+ if (PySet_Add(features, feature) == -1) {
+ return;
+ }
+
+ Py_DECREF(feature);
+#endif
+
if (PyObject_SetAttrString(m, "backend_features", features) == -1) {
return;
}
diff --git a/setup_zstd.py b/setup_zstd.py
index 399b129..d940c80 100644
--- a/setup_zstd.py
+++ b/setup_zstd.py
@@ -78,6 +78,7 @@ def get_c_extension(
if system_zstd:
extra_args.append("-DZSTD_MULTITHREAD")
+ extra_args.append("-DSYSTEM_ZSTD")
else:
extra_args.append("-DZSTD_SINGLE_FILE")
extra_args.append("-DZSTDLIB_VISIBILITY=")
diff --git a/tests/test_module_attributes.py b/tests/test_module_attributes.py
index d487aa8..15cda73 100644
--- a/tests/test_module_attributes.py
+++ b/tests/test_module_attributes.py
@@ -26,7 +26,15 @@ class TestModuleAttributes(unittest.TestCase):
},
}[zstd.backend]
- self.assertEqual(zstd.backend_features, expected)
+ # The following features are available only with
+ # statically linked version of the module.
+ available_features = set(zstd.backend_features)
+ if 'system_zstd' in available_features:
+ available_features.remove('system_zstd')
+ expected.discard('multi_compress_to_buffer')
+ expected.discard('multi_decompress_to_buffer')
+
+ self.assertEqual(available_features, expected)
def test_constants(self):
self.assertEqual(zstd.MAX_COMPRESSION_LEVEL, 22)

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Feb 17 12:46:17 UTC 2023 - Martin Liška <mliska@suse.cz>
- Enable --system-zstd so that we depend of a system shared library
of zstd.
- Add feature-detection.patch as feature detection test does not support
--system-zstd (gh#indygreg/python-zstandard#191).
-------------------------------------------------------------------
Mon Dec 5 18:21:01 UTC 2022 - Yogalakshmi Arunachalam <yarunachalam@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package python-zstandard
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -25,6 +25,7 @@ License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://github.com/indygreg/python-zstandard
Source: https://files.pythonhosted.org/packages/source/z/zstandard/zstandard-%{version}.tar.gz
Patch0: feature-detection.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
@ -48,10 +49,11 @@ Zstandard bindings for Python
%prep
%setup -q -n zstandard-%{version}
%patch0 -p1
%build
export CFLAGS="%{optflags}"
%python_build
%python_build --system-zstd
%install
%python_install