Notification time stamped 2023-06-30 15:14:32 UTC
From 27eafa11ea5f97933d7a372e3835d46fbc1b578e Mon Sep 17 00:00:00 2001 From: Miro Hrončok miro@hroncok.cz Date: Jun 07 2021 22:48:34 +0000 Subject: Python 3.10 compatibility
---
diff --git a/python-zstd-1.4.5.1-py_ssize_t_clean.patch b/python-zstd-1.4.5.1-py_ssize_t_clean.patch new file mode 100644 index 0000000..b37c4b5 --- /dev/null +++ b/python-zstd-1.4.5.1-py_ssize_t_clean.patch @@ -0,0 +1,88 @@ +--- a/src/python-zstd.c ++++ b/src/python-zstd.c +@@ -29,13 +29,16 @@ + + #include <stdlib.h> + #include <stddef.h> ++ ++/* Since 3.8 it is mandatory to use proper type for # formats */ ++#define PY_SSIZE_T_CLEAN + #include <Python.h> ++ + #include "bytesobject.h" + #include "zstd.h" + #include "util.h" + #include "python-zstd.h" + +- + /** + * New function for multi-threaded compression. + * Uses origin zstd header, nothing more. +@@ -47,12 +50,13 @@ + + PyObject *result; + const char *source; +- uint32_t source_size; ++ Py_ssize_t source_size; + char *dest; +- uint32_t dest_size; ++ Py_ssize_t dest_size; + size_t cSize; + int32_t level = ZSTD_CLEVEL_DEFAULT; + int32_t threads = 0; ++ ZSTD_CCtx* cctx = 0; + + #if PY_MAJOR_VERSION >= 3 + if (!PyArg_ParseTuple(args, "y#|ii", &source, &source_size, &level, &threads)) +@@ -87,7 +91,7 @@ + return NULL; + } + +- dest_size = ZSTD_compressBound(source_size); ++ dest_size = (Py_ssize_t)ZSTD_compressBound(source_size); + result = PyBytes_FromStringAndSize(NULL, dest_size); + if (result == NULL) { + return NULL; +@@ -96,12 +100,13 @@ + if (source_size > 0) { + dest = PyBytes_AS_STRING(result); + +- ZSTD_CCtx* cctx = ZSTD_createCCtx(); ++ cctx = ZSTD_createCCtx(); ++ + ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, level); + ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, threads); + + Py_BEGIN_ALLOW_THREADS +- cSize = ZSTD_compress2(cctx, dest, dest_size, source, source_size); ++ cSize = ZSTD_compress2(cctx, dest, (size_t)dest_size, source, (size_t)source_size); + Py_END_ALLOW_THREADS + + ZSTD_freeCCtx(cctx); +@@ -126,7 +131,7 @@ + + PyObject *result; + const char *source; +- uint32_t source_size; ++ Py_ssize_t source_size; + uint64_t dest_size; + char error = 0; + size_t cSize; +@@ -233,7 +238,7 @@ + + PyObject *result; + const char *source; +- uint32_t source_size; ++ Py_ssize_t source_size; + char *dest; + uint32_t dest_size; + size_t cSize; +@@ -289,7 +294,7 @@ + + PyObject *result; + const char *source; +- uint32_t source_size; ++ Py_ssize_t source_size; + uint32_t dest_size; + size_t cSize; + diff --git a/python-zstd-1.4.5.1-test-external.patch b/python-zstd-1.4.5.1-test-external.patch index 9b99d16..548810f 100644 --- a/python-zstd-1.4.5.1-test-external.patch +++ b/python-zstd-1.4.5.1-test-external.patch @@ -1,5 +1,5 @@ ---- zstd-1.3.8.1/setup.py.orig 2019-03-04 17:40:51.208528890 +0700 -+++ zstd-1.3.8.1/setup.py 2019-03-04 17:58:37.644953996 +0700 +--- a/setup.py ++++ b/setup.py @@ -97,6 +97,8 @@ class ZstdBuildExt( build_ext ):
diff --git a/python-zstd-1.4.5.1-test-once.patch b/python-zstd-1.4.5.1-test-once.patch index 3246edf..438523d 100644 --- a/python-zstd-1.4.5.1-test-once.patch +++ b/python-zstd-1.4.5.1-test-once.patch @@ -1,5 +1,5 @@ ---- zstd-1.3.8.1/setup.py.orig 2019-03-04 17:40:51.208528890 +0700 -+++ zstd-1.3.8.1/setup.py 2019-03-04 17:58:37.644953996 +0700 +--- a/setup.py ++++ b/setup.py @@ -171,7 +173,6 @@ Extension('zstd', zstdFiles, libraries=ext_libraries) ], diff --git a/python-zstd.spec b/python-zstd.spec index 22376a8..17cdaf2 100644 --- a/python-zstd.spec +++ b/python-zstd.spec @@ -14,6 +14,10 @@ Source0: %{pypi_source} Patch0: python-zstd-1.4.5.1-test-external.patch Patch1: python-zstd-1.4.5.1-test-once.patch
+# Python 3.10 compatibility, merged upstream +# From https://github.com/sergey-dryabzhinsky/python-zstd/commit/428a31edcd +Patch2: python-zstd-1.4.5.1-py_ssize_t_clean.patch + BuildRequires: gcc BuildRequires: python3-devel BuildRequires: python3dist(setuptools) @@ -33,7 +37,7 @@ Simple Python bindings for the Zstd compression library.
%prep -%autosetup -n %{pypi_name}-%{version} +%autosetup -p1 -n %{pypi_name}-%{version} # Remove bundled egg-info rm -rf %{pypi_name}.egg-info # Remove bundled zstd library
https://src.fedoraproject.org/rpms/python-zstd/c/27eafa11ea5f97933d7a372e383...