!6 Update package
From: @liqiuyu123 Reviewed-by: @yangzhao_kl Signed-off-by: @yangzhao_kl
This commit is contained in:
commit
498353c7b5
@ -1,179 +0,0 @@
|
||||
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,13 +1,11 @@
|
||||
%global _empty_manifest_terminate_build 0
|
||||
Name: python-zstd
|
||||
Version: 1.5.1.0
|
||||
Version: 1.5.2.5
|
||||
Release: 1
|
||||
Summary: ZSTD Bindings for Python
|
||||
License: BSD-2-Clause
|
||||
URL: https://github.com/sergey-dryabzhinsky/python-zstd
|
||||
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
|
||||
|
||||
Source0: https://files.pythonhosted.org/packages/3d/3a/296aad7054ef4ec1f5c66d6a4aacd77cb0bc6d005064cca5c40d0169f196/zstd-1.5.2.5.tar.gz
|
||||
|
||||
%description
|
||||
Simple Python bindings for the Zstd compression library.
|
||||
@ -19,9 +17,7 @@ Provides: python3-zstd
|
||||
BuildRequires: gcc
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools
|
||||
BuildRequires: python3-pbr
|
||||
BuildRequires: python3-pip
|
||||
BuildRequires: python3-wheel
|
||||
BuildRequires: python3-cffi
|
||||
%description -n python3-zstd
|
||||
Simple Python bindings for the Zstd compression library.
|
||||
|
||||
@ -32,14 +28,13 @@ Provides: python3-zstd-doc
|
||||
Simple Python bindings for the Zstd compression library.
|
||||
|
||||
%prep
|
||||
%autosetup -n zstd-1.5.1.0 -p1
|
||||
%autosetup -n zstd-1.5.2.5
|
||||
|
||||
%build
|
||||
%py3_build
|
||||
|
||||
%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
|
||||
@ -70,12 +65,15 @@ mv %{buildroot}/doclist.lst .
|
||||
%{__python3} setup.py test
|
||||
|
||||
%files -n python3-zstd -f filelist.lst
|
||||
%license LICENSE
|
||||
%doc README.rst
|
||||
%dir %{python3_sitearch}/*
|
||||
|
||||
%files help -f doclist.lst
|
||||
%{_docdir}/*
|
||||
|
||||
%changelog
|
||||
* 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
|
||||
|
||||
|
||||
Binary file not shown.
BIN
zstd-1.5.2.5.tar.gz
Normal file
BIN
zstd-1.5.2.5.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user