Python 3.10 compatibility
This commit is contained in:
parent
629a1123df
commit
27eafa11ea
88
python-zstd-1.4.5.1-py_ssize_t_clean.patch
Normal file
88
python-zstd-1.4.5.1-py_ssize_t_clean.patch
Normal file
@ -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;
|
||||
|
||||
@ -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 ):
|
||||
|
||||
|
||||
@ -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)
|
||||
],
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user