!5 upgrade the version to 1.5.1.0
From: @huyuqi2 Reviewed-by: @shinwell_hu Signed-off-by: @shinwell_hu
This commit is contained in:
commit
e167103524
179
0001-fix-python3.8+-use-py_ssize-t-type.patch
Normal file
179
0001-fix-python3.8+-use-py_ssize-t-type.patch
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
From 0fe320d4e2d44349aace1ca0876dd044c7048ff8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: yuqi <yuqi@isrc.iscas.ac.cn>
|
||||||
|
Date: Fri, 3 Jun 2022 16:06:42 +0000
|
||||||
|
Subject: [PATCH] fix python3.8+ use py_ssize t-type
|
||||||
|
|
||||||
|
---
|
||||||
|
src/python-zstd.c | 140 +++++++++++++++++++++++++++++++++++++++++++++-
|
||||||
|
1 file changed, 138 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/python-zstd.c b/src/python-zstd.c
|
||||||
|
index ab1d0ed..10ccc35 100644
|
||||||
|
--- a/src/python-zstd.c
|
||||||
|
+++ b/src/python-zstd.c
|
||||||
|
@@ -214,13 +214,144 @@ static PyObject *py_zstd_library_version_int(PyObject* self, PyObject *args)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
- * Returns 0 or 1 if ZSTD library build as external
|
||||||
|
- */
|
||||||
|
+ * Returns 0 or 1 if ZSTD library build as external*/
|
||||||
|
+
|
||||||
|
static PyObject *py_zstd_library_external(PyObject* self, PyObject *args)
|
||||||
|
{
|
||||||
|
return Py_BuildValue("i", LIBZSTD_EXTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#if PYZSTD_LEGACY > 0
|
||||||
|
+
|
||||||
|
+#pragma message "Old style functions are deprecated since 2018-05-06 and may be removed any time!"
|
||||||
|
+
|
||||||
|
+/* Macros and other changes from python-lz4.c
|
||||||
|
+ * Copyright (c) 2012-2013, Steeve Morin
|
||||||
|
+ * All rights reserved. */
|
||||||
|
+
|
||||||
|
+static inline void store_le32(char *c, uint32_t x) {
|
||||||
|
+ c[0] = x & 0xff;
|
||||||
|
+ c[1] = (x >> 8) & 0xff;
|
||||||
|
+ c[2] = (x >> 16) & 0xff;
|
||||||
|
+ c[3] = (x >> 24) & 0xff;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static inline uint32_t load_le32(const char *c) {
|
||||||
|
+ const uint8_t *d = (const uint8_t *)c;
|
||||||
|
+ return d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static const uint32_t hdr_size = sizeof(uint32_t);
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+static PyObject *py_zstd_compress_old(PyObject* self, PyObject *args) {
|
||||||
|
+/**
|
||||||
|
+ * Old format with custom header
|
||||||
|
+ * @deprecated
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ PyObject *result;
|
||||||
|
+ const char *source;
|
||||||
|
+ Py_ssize_t source_size;
|
||||||
|
+ char *dest;
|
||||||
|
+ uint32_t dest_size;
|
||||||
|
+ size_t cSize;
|
||||||
|
+ int32_t level = ZSTD_CLEVEL_DEFAULT;
|
||||||
|
+
|
||||||
|
+#if PY_MAJOR_VERSION >= 3
|
||||||
|
+ if (!PyArg_ParseTuple(args, "y#|i", &source, &source_size, &level))
|
||||||
|
+ return NULL;
|
||||||
|
+#else
|
||||||
|
+ if (!PyArg_ParseTuple(args, "s#|i", &source, &source_size, &level))
|
||||||
|
+ return NULL;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+ /* This is old version function - no Error raising here. */
|
||||||
|
+#if ZSTD_VERSION_NUMBER >= 10304
|
||||||
|
+ /* Fast levels (zstd >= 1.3.4) */
|
||||||
|
+ if (level < ZSTD_MIN_CLEVEL) level=ZSTD_MIN_CLEVEL;
|
||||||
|
+ if (0 == level) level=ZSTD_CLEVEL_DEFAULT;
|
||||||
|
+#else
|
||||||
|
+ if (level <= 0) level=ZSTD_CLEVEL_DEFAULT;
|
||||||
|
+#endif
|
||||||
|
+ if (level > ZSTD_MAX_CLEVEL) level=ZSTD_MAX_CLEVEL;
|
||||||
|
+
|
||||||
|
+ dest_size = ZSTD_compressBound(source_size);
|
||||||
|
+ result = PyBytes_FromStringAndSize(NULL, hdr_size + dest_size);
|
||||||
|
+ if (result == NULL) {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+ dest = PyBytes_AS_STRING(result);
|
||||||
|
+
|
||||||
|
+ store_le32(dest, source_size);
|
||||||
|
+ if (source_size > 0) {
|
||||||
|
+
|
||||||
|
+ Py_BEGIN_ALLOW_THREADS
|
||||||
|
+ cSize = ZSTD_compress(dest + hdr_size, dest_size, source, source_size, level);
|
||||||
|
+ Py_END_ALLOW_THREADS
|
||||||
|
+
|
||||||
|
+ if (ZSTD_isError(cSize)) {
|
||||||
|
+ PyErr_Format(ZstdError, "Compression error: %s", ZSTD_getErrorName(cSize));
|
||||||
|
+ Py_CLEAR(result);
|
||||||
|
+ } else {
|
||||||
|
+ Py_SIZE(result) = cSize + hdr_size;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return result;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static PyObject *py_zstd_uncompress_old(PyObject* self, PyObject *args) {
|
||||||
|
+/**
|
||||||
|
+ * Old format with custom header
|
||||||
|
+ * @deprecated
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ PyObject *result;
|
||||||
|
+ const char *source;
|
||||||
|
+ Py_ssize_t source_size;
|
||||||
|
+ uint32_t dest_size;
|
||||||
|
+ size_t cSize;
|
||||||
|
+
|
||||||
|
+#if PY_MAJOR_VERSION >= 3
|
||||||
|
+ if (!PyArg_ParseTuple(args, "y#", &source, &source_size))
|
||||||
|
+ return NULL;
|
||||||
|
+#else
|
||||||
|
+ if (!PyArg_ParseTuple(args, "s#", &source, &source_size))
|
||||||
|
+ return NULL;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+ if (source_size < hdr_size) {
|
||||||
|
+ PyErr_SetString(PyExc_ValueError, "input too short");
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+ dest_size = load_le32(source);
|
||||||
|
+ if (dest_size > INT_MAX) {
|
||||||
|
+ PyErr_Format(PyExc_ValueError, "invalid size in header: 0x%x", dest_size);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+ result = PyBytes_FromStringAndSize(NULL, dest_size);
|
||||||
|
+
|
||||||
|
+ if (result != NULL && dest_size > 0) {
|
||||||
|
+ char *dest = PyBytes_AS_STRING(result);
|
||||||
|
+
|
||||||
|
+ Py_BEGIN_ALLOW_THREADS
|
||||||
|
+ cSize = ZSTD_decompress(dest, dest_size, source + hdr_size, source_size - hdr_size);
|
||||||
|
+ Py_END_ALLOW_THREADS
|
||||||
|
+
|
||||||
|
+ if (ZSTD_isError(cSize)) {
|
||||||
|
+ PyErr_Format(ZstdError, "Decompression error: %s", ZSTD_getErrorName(cSize));
|
||||||
|
+ Py_CLEAR(result);
|
||||||
|
+ } else if (cSize != dest_size) {
|
||||||
|
+ PyErr_Format(ZstdError, "Decompression error: length mismatch - %u [Dcp] != %u [Hdr]", (uint32_t)cSize, dest_size);
|
||||||
|
+ Py_CLEAR(result);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return result;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#endif // PYZSTD_LEGACY
|
||||||
|
+
|
||||||
|
|
||||||
|
static PyMethodDef ZstdMethods[] = {
|
||||||
|
{"ZSTD_compress", py_zstd_compress_mt, METH_VARARGS, COMPRESS_DOCSTRING},
|
||||||
|
@@ -234,6 +365,10 @@ static PyMethodDef ZstdMethods[] = {
|
||||||
|
{"ZSTD_version", py_zstd_library_version, METH_NOARGS, ZSTD_VERSION_DOCSTRING},
|
||||||
|
{"ZSTD_version_number", py_zstd_library_version_int, METH_NOARGS, ZSTD_INT_VERSION_DOCSTRING},
|
||||||
|
{"ZSTD_external", py_zstd_library_external, METH_NOARGS, ZSTD_EXTERNAL_DOCSTRING},
|
||||||
|
+#if PYZSTD_LEGACY > 0
|
||||||
|
+ {"compress_old", py_zstd_compress_old, METH_VARARGS, COMPRESS_OLD_DOCSTRING},
|
||||||
|
+ {"decompress_old", py_zstd_uncompress_old, METH_VARARGS, UNCOMPRESS_OLD_DOCSTRING},
|
||||||
|
+#endif
|
||||||
|
{NULL, NULL, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -303,3 +438,4 @@ void initzstd(void)
|
||||||
|
return module;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
+
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,102 +0,0 @@
|
|||||||
From 8242ae139f70a228bbcd8e7ca28f235ec0654180 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Sergey Dryabzhinsky <sergey.dryabzhinsky@gmail.com>
|
|
||||||
Date: Fri, 16 Apr 2021 21:40:23 +0300
|
|
||||||
Subject: [PATCH] fix python3.8+ use py_ssize_t type
|
|
||||||
|
|
||||||
---
|
|
||||||
src/python-zstd.c | 23 ++++++++++++++---------
|
|
||||||
1 file changed, 14 insertions(+), 9 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/python-zstd.c b/src/python-zstd.c
|
|
||||||
index 1cf7b61..9ce1577 100644
|
|
||||||
--- 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 @@ static PyObject *py_zstd_compress_mt(PyObject* self, PyObject *args)
|
|
||||||
|
|
||||||
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 @@ static PyObject *py_zstd_compress_mt(PyObject* self, PyObject *args)
|
|
||||||
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 @@ static PyObject *py_zstd_compress_mt(PyObject* self, PyObject *args)
|
|
||||||
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 @@ static PyObject *py_zstd_uncompress(PyObject* self, PyObject *args)
|
|
||||||
|
|
||||||
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 @@ static PyObject *py_zstd_compress_old(PyObject* self, PyObject *args) {
|
|
||||||
|
|
||||||
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 @@ static PyObject *py_zstd_uncompress_old(PyObject* self, PyObject *args) {
|
|
||||||
|
|
||||||
PyObject *result;
|
|
||||||
const char *source;
|
|
||||||
- uint32_t source_size;
|
|
||||||
+ Py_ssize_t source_size;
|
|
||||||
uint32_t dest_size;
|
|
||||||
size_t cSize;
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,17 +1,13 @@
|
|||||||
|
%global _empty_manifest_terminate_build 0
|
||||||
Name: python-zstd
|
Name: python-zstd
|
||||||
Version: 1.4.8.1
|
Version: 1.5.1.0
|
||||||
Release: 3
|
Release: 1
|
||||||
Summary: ZSTD Bindings for Python
|
Summary: ZSTD Bindings for Python
|
||||||
License: BSD-2-Clause
|
License: BSD-2-Clause
|
||||||
URL: https://github.com/sergey-dryabzhinsky/python-zstd
|
URL: https://github.com/sergey-dryabzhinsky/python-zstd
|
||||||
Source0: https://files.pythonhosted.org/packages/92/bc/6bc155c61db55d5b3111a8afc76aaec084372bde89a82ecd4f5fd96c639a/zstd-1.4.8.1.tar.gz
|
Source0: https://files.pythonhosted.org/packages/3d/bc/189c72d298fea928efabef9a5cb9a7b55adff71f27eadad62890c1e4b32f/zstd-1.5.1.0.tar.gz
|
||||||
|
Patch1: 0001-fix-python3.8+-use-py_ssize-t-type.patch
|
||||||
|
|
||||||
# https://github.com/sergey-dryabzhinsky/python-zstd/commit/428a31edcde94d2908aa8ca3439ca01a797de3a4
|
|
||||||
Patch1: fix-python3.8+-use-py_ssize_t-type.patch
|
|
||||||
|
|
||||||
BuildRequires: gcc
|
|
||||||
BuildRequires: python3-devel
|
|
||||||
BuildRequires: python3-setuptools
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Simple Python bindings for the Zstd compression library.
|
Simple Python bindings for the Zstd compression library.
|
||||||
@ -19,29 +15,70 @@ Simple Python bindings for the Zstd compression library.
|
|||||||
%package -n python3-zstd
|
%package -n python3-zstd
|
||||||
Summary: %{summary}
|
Summary: %{summary}
|
||||||
Provides: python3-zstd
|
Provides: python3-zstd
|
||||||
# The library does not do symbol versioning to fully match automatically on
|
# Base build requires
|
||||||
|
BuildRequires: gcc
|
||||||
|
BuildRequires: python3-devel
|
||||||
|
BuildRequires: python3-setuptools
|
||||||
|
BuildRequires: python3-pbr
|
||||||
|
BuildRequires: python3-pip
|
||||||
|
BuildRequires: python3-wheel
|
||||||
%description -n python3-zstd
|
%description -n python3-zstd
|
||||||
Simple Python bindings for the Zstd compression library.
|
Simple Python bindings for the Zstd compression library.
|
||||||
|
|
||||||
|
%package help
|
||||||
|
Summary: ZSTD Bindings for Python
|
||||||
|
Provides: python3-zstd-doc
|
||||||
|
%description help
|
||||||
|
Simple Python bindings for the Zstd compression library.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n zstd-1.4.8.1 -p1
|
%autosetup -n zstd-1.5.1.0 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%py3_build
|
%py3_build
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%py3_install
|
%py3_install
|
||||||
|
|
||||||
|
install -d -m755 %{buildroot}/%{_pkgdocdir}
|
||||||
|
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
|
||||||
|
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
|
||||||
|
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
|
||||||
|
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
|
||||||
|
pushd %{buildroot}
|
||||||
|
if [ -d usr/lib ]; then
|
||||||
|
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
|
||||||
|
fi
|
||||||
|
if [ -d usr/lib64 ]; then
|
||||||
|
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
|
||||||
|
fi
|
||||||
|
if [ -d usr/bin ]; then
|
||||||
|
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
|
||||||
|
fi
|
||||||
|
if [ -d usr/sbin ]; then
|
||||||
|
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
|
||||||
|
fi
|
||||||
|
touch doclist.lst
|
||||||
|
if [ -d usr/share/man ]; then
|
||||||
|
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
mv %{buildroot}/filelist.lst .
|
||||||
|
mv %{buildroot}/doclist.lst .
|
||||||
|
|
||||||
%check
|
%check
|
||||||
%{__python3} setup.py test
|
%{__python3} setup.py test
|
||||||
|
|
||||||
%files -n python3-zstd
|
%files -n python3-zstd -f filelist.lst
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
%doc README.rst
|
%doc README.rst
|
||||||
%{python3_sitearch}/zstd-1.4.8.1-py%{python3_version}.egg-info
|
%files help -f doclist.lst
|
||||||
%{python3_sitearch}/zstd*.so
|
%{_docdir}/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* 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
|
* Tue May 10 2022 yangping <yangping69@h-partners> - 1.4.8.1-3
|
||||||
- License compliance rectification
|
- License compliance rectification
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
BIN
zstd-1.5.1.0.tar.gz
Normal file
BIN
zstd-1.5.1.0.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user