summaryrefslogtreecommitdiff
path: root/dev-python/zstandard
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2025-02-24 19:24:56 +0000
committerV3n3RiX <venerix@koprulu.sector>2025-02-24 19:24:56 +0000
commitd4653056cc74d97f24bef0d56b4ebe11c53c8b76 (patch)
tree5d4be0715302fad2089468027fadaa0372afd1d1 /dev-python/zstandard
parent575bcb9220287a6f0d2577db1fd9fe55d9d8b745 (diff)
gentoo auto-resync : 24:02:2025 - 19:24:56
Diffstat (limited to 'dev-python/zstandard')
-rw-r--r--dev-python/zstandard/Manifest2
-rw-r--r--dev-python/zstandard/files/zstandard-0.23.0-zstd-1.5.7.patch163
-rw-r--r--dev-python/zstandard/zstandard-0.23.0-r2.ebuild81
3 files changed, 246 insertions, 0 deletions
diff --git a/dev-python/zstandard/Manifest b/dev-python/zstandard/Manifest
index 717d5a5acc31..4e69fe6ff555 100644
--- a/dev-python/zstandard/Manifest
+++ b/dev-python/zstandard/Manifest
@@ -1,3 +1,5 @@
+AUX zstandard-0.23.0-zstd-1.5.7.patch 6515 BLAKE2B 9e8b8e16405f7ef75f9bf122e51c5ac9a40ca4868346d9586278c55befe0da70dc51c816328667a82306447732d35a1deac0df5acba66aadeaaf5df19aef4f73 SHA512 1bd96eea464ad8fb469abd0bedfc9247053c3baa48654e34df4676222be61b7d99a87184b99c5bd3418e15c2ec088f83d71b7ad9a0323b7f9a6972a29c733abb
DIST python-zstandard-0.23.0.gh.tar.gz 732448 BLAKE2B 920b53dc4a221059411062229ddf0ff51c478c2212e5599dec21298fef8e30b7a160c2f7d958ef95251ce5fb1357eaf4a8c3e4eca37304ef7a43176f723f3394 SHA512 06d799f8c5e89e5cc2f5b8ff100aeb3c3ff938757ce39852affb075487f65406d7d3f6d611b1864ec025fff86a51bf15b80c8af6260beda050b4fef5b7edd206
EBUILD zstandard-0.23.0-r1.ebuild 1895 BLAKE2B b902b5ef065c4232d2ebc8fa3714b42ef6b136051f0086907043f68087bd28586aeac36e69158fbfb4102c56a8f1daf9f00b525fc4bbc13133c38810e9223317 SHA512 ecda9eb4ca319f254559c2b40b1cb79a05e7ac847d4ef7528c779c1750cbc3ce48063e779a0cff47fb50bfa538800caa8dadbe5b382eee1cb3ae56990f13a53e
+EBUILD zstandard-0.23.0-r2.ebuild 1950 BLAKE2B 585a733067f6f0afa90e1a062733fb9c72eadcd86cd6a556cc63721daaa78c48dbfba60e2a66952694cecd05bd5e000c7c7bdfb717a669a2c64255faf07ecbaa SHA512 ad05a2083cd6652f5cbd587412985e4edff5d93c0c440e2cfc2c52aa17f5ae5fe1b16e7709086f7149c175eb6cddb7060d8cbf108f7c5969be640593c43f508e
MISC metadata.xml 378 BLAKE2B dd5834c84bb375812b3a3cfcc00d29aa43ac8954b044e188e8f38bdca93fdf1ce98fe78b78dbeccd935c83ca10f3ce18f893e5720dd8991118b6c69149a4ac61 SHA512 06554d973b525d53c680c3e43041f33125dad222339e645294fbc22670a7eadb0e9bf8a3b0771d2b2fb8f136d958eadb32c295179d1547c50ae26754360609f3
diff --git a/dev-python/zstandard/files/zstandard-0.23.0-zstd-1.5.7.patch b/dev-python/zstandard/files/zstandard-0.23.0-zstd-1.5.7.patch
new file mode 100644
index 000000000000..c9d1c1d8690d
--- /dev/null
+++ b/dev-python/zstandard/files/zstandard-0.23.0-zstd-1.5.7.patch
@@ -0,0 +1,163 @@
+From 33c483f2df0be8de9df847c7cdfa9f9b32afc7aa Mon Sep 17 00:00:00 2001
+From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
+Date: Fri, 21 Feb 2025 20:59:18 +0100
+Subject: [PATCH 1/3] Use zstd-1.5.7
+
+this changed compression results, so we have to adapt tests
+---
+ c-ext/backend_c.c | 2 +-
+ tests/test_compressor_compress.py | 2 +-
+ tests/test_compressor_compressobj.py | 2 +-
+ tests/test_compressor_copy_stream.py | 2 +-
+ tests/test_compressor_stream_writer.py | 2 +-
+ tests/test_module_attributes.py | 2 +-
+ 6 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/c-ext/backend_c.c b/c-ext/backend_c.c
+index aabe30b..4b09d1f 100644
+--- a/c-ext/backend_c.c
++++ b/c-ext/backend_c.c
+@@ -152,7 +152,7 @@ void zstd_module_init(PyObject *m) {
+ PyObject *features = NULL;
+ PyObject *feature = NULL;
+ unsigned zstd_ver_no = ZSTD_versionNumber();
+- unsigned our_hardcoded_version = 10506;
++ unsigned our_hardcoded_version = 10507;
+ if (ZSTD_VERSION_NUMBER != our_hardcoded_version ||
+ zstd_ver_no != our_hardcoded_version) {
+ PyErr_Format(
+diff --git a/tests/test_compressor_compress.py b/tests/test_compressor_compress.py
+index d96d476..c978c19 100644
+--- a/tests/test_compressor_compress.py
++++ b/tests/test_compressor_compress.py
+@@ -52,7 +52,7 @@ class TestCompressor_compress(unittest.TestCase):
+
+ cctx = zstd.ZstdCompressor(level=3, write_content_size=False)
+ result = cctx.compress(b"".join(chunks))
+- self.assertEqual(len(result), 999)
++ self.assertEqual(len(result), 1029)
+ self.assertEqual(result[0:4], b"\x28\xb5\x2f\xfd")
+
+ # This matches the test for read_to_iter() below.
+diff --git a/tests/test_compressor_compressobj.py b/tests/test_compressor_compressobj.py
+index f429b32..b89ae20 100644
+--- a/tests/test_compressor_compressobj.py
++++ b/tests/test_compressor_compressobj.py
+@@ -39,7 +39,7 @@ class TestCompressor_compressobj(unittest.TestCase):
+ cobj = cctx.compressobj()
+
+ result = cobj.compress(b"".join(chunks)) + cobj.flush()
+- self.assertEqual(len(result), 999)
++ self.assertEqual(len(result), 1029)
+ self.assertEqual(result[0:4], b"\x28\xb5\x2f\xfd")
+
+ params = zstd.get_frame_parameters(result)
+diff --git a/tests/test_compressor_copy_stream.py b/tests/test_compressor_copy_stream.py
+index 82c7ce7..685660f 100644
+--- a/tests/test_compressor_copy_stream.py
++++ b/tests/test_compressor_copy_stream.py
+@@ -50,7 +50,7 @@ class TestCompressor_copy_stream(unittest.TestCase):
+ r, w = cctx.copy_stream(source, dest)
+
+ self.assertEqual(r, 255 * 16384)
+- self.assertEqual(w, 999)
++ self.assertEqual(w, 1029)
+
+ params = zstd.get_frame_parameters(dest.getvalue())
+ self.assertEqual(params.content_size, zstd.CONTENTSIZE_UNKNOWN)
+diff --git a/tests/test_compressor_stream_writer.py b/tests/test_compressor_stream_writer.py
+index cfa198b..3baa788 100644
+--- a/tests/test_compressor_stream_writer.py
++++ b/tests/test_compressor_stream_writer.py
+@@ -301,7 +301,7 @@ class TestCompressor_stream_writer(unittest.TestCase):
+ d = zstd.train_dictionary(8192, samples)
+
+ h = hashlib.sha1(d.as_bytes()).hexdigest()
+- self.assertEqual(h, "a46d2f7a3bc3357c9d717d3dadf9a26fde23e93d")
++ self.assertEqual(h, "f32ddfbe0878bbd428afc00b17810387c6752191")
+
+ buffer = io.BytesIO()
+ cctx = zstd.ZstdCompressor(level=9, dict_data=d)
+diff --git a/tests/test_module_attributes.py b/tests/test_module_attributes.py
+index a99ed2e..3e3b482 100644
+--- a/tests/test_module_attributes.py
++++ b/tests/test_module_attributes.py
+@@ -5,7 +5,7 @@ import zstandard as zstd
+
+ class TestModuleAttributes(unittest.TestCase):
+ def test_version(self):
+- self.assertEqual(zstd.ZSTD_VERSION, (1, 5, 6))
++ self.assertEqual(zstd.ZSTD_VERSION, (1, 5, 7))
+
+ self.assertEqual(zstd.__version__, "0.23.0")
+
+From f598b951f36b6259fd7871892dd1e136f96c58ec Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Mon, 24 Feb 2025 11:30:29 +0100
+Subject: [PATCH 2/3] Update make_cffi.py to skip type alias macros in zstd
+ 1.5.7
+
+---
+ make_cffi.py | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/make_cffi.py b/make_cffi.py
+index 170d1e5..763abb2 100644
+--- a/make_cffi.py
++++ b/make_cffi.py
+@@ -179,7 +179,7 @@ ffi.set_source(
+ include_dirs=INCLUDE_DIRS,
+ )
+
+-DEFINE = re.compile(b"^\\#define ([a-zA-Z0-9_]+) ")
++DEFINE = re.compile(rb"^#define\s+([a-zA-Z0-9_]+)\s+(\S+)")
+
+ sources = []
+
+@@ -204,9 +204,14 @@ for header in HEADERS:
+ if m.group(1) in (b"ZSTD_LIB_VERSION", b"ZSTD_VERSION_STRING"):
+ continue
+
++ # These defines create aliases from old (camelCase) type names
++ # to the new PascalCase names, which breaks CFFI.
++ if m.group(1).lower() == m.group(2).lower():
++ continue
++
+ # The ... is magic syntax by the cdef parser to resolve the
+ # value at compile time.
+- sources.append(m.group(0) + b" ...")
++ sources.append(b"#define " + m.group(1) + b" ...")
+
+ cdeflines = b"\n".join(sources).splitlines()
+ cdeflines = [l for l in cdeflines if l.strip()]
+From fb56d2b5ab38132bff998b15a0d3de4e91569167 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Mon, 24 Feb 2025 11:30:46 +0100
+Subject: [PATCH 3/3] Update backend_cffi for new type names in zstd 1.5.7
+
+---
+ zstandard/backend_cffi.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/zstandard/backend_cffi.py b/zstandard/backend_cffi.py
+index 80d6fc8..38427f4 100644
+--- a/zstandard/backend_cffi.py
++++ b/zstandard/backend_cffi.py
+@@ -2574,7 +2574,7 @@ def get_frame_parameters(data):
+ :return:
+ :py:class:`FrameParameters`
+ """
+- params = ffi.new("ZSTD_frameHeader *")
++ params = ffi.new("ZSTD_FrameHeader *")
+
+ data_buffer = ffi.from_buffer(data)
+ zresult = lib.ZSTD_getFrameHeader(params, data_buffer, len(data_buffer))
+@@ -4289,7 +4289,7 @@ class ZstdDecompressor(object):
+
+ # All chunks should be zstd frames and should have content size set.
+ chunk_buffer = ffi.from_buffer(chunk)
+- params = ffi.new("ZSTD_frameHeader *")
++ params = ffi.new("ZSTD_FrameHeader *")
+ zresult = lib.ZSTD_getFrameHeader(
+ params, chunk_buffer, len(chunk_buffer)
+ )
diff --git a/dev-python/zstandard/zstandard-0.23.0-r2.ebuild b/dev-python/zstandard/zstandard-0.23.0-r2.ebuild
new file mode 100644
index 000000000000..b82bca58b70b
--- /dev/null
+++ b/dev-python/zstandard/zstandard-0.23.0-r2.ebuild
@@ -0,0 +1,81 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..13} pypy3 pypy3_11 )
+
+inherit distutils-r1
+
+MY_P=python-zstandard-${PV}
+DESCRIPTION="Zstandard Bindings for Python"
+HOMEPAGE="
+ https://github.com/indygreg/python-zstandard/
+ https://pypi.org/project/zstandard/
+"
+SRC_URI="
+ https://github.com/indygreg/python-zstandard/archive/${PV}.tar.gz
+ -> ${MY_P}.gh.tar.gz
+"
+S=${WORKDIR}/${MY_P}
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
+
+DEPEND="
+ >=app-arch/zstd-1.5.7:=
+"
+RDEPEND="
+ ${DEPEND}
+ $(python_gen_cond_dep '
+ >=dev-python/cffi-1.14.0-r2:=[${PYTHON_USEDEP}]
+ ' 'python*')
+"
+BDEPEND="
+ test? (
+ dev-python/hypothesis[${PYTHON_USEDEP}]
+ )
+"
+
+distutils_enable_tests pytest
+
+src_prepare() {
+ local PATCHES=(
+ # https://github.com/indygreg/python-zstandard/pull/255
+ "${FILESDIR}/${P}-zstd-1.5.7.patch"
+ )
+
+ # the C backend is repeatedly broken, so force CFFI instead
+ sed -e '/PYTHON_ZSTANDARD_IMPORT_POLICY/s:default:cffi:' \
+ -i zstandard/__init__.py || die
+ # unbundle zstd
+ rm zstd/* || die
+ > zstd/zstd.c || die
+ # it does random preprocessing on that, so we can't use #include
+ local f
+ for f in zdict.h zstd.h; do
+ cp "${ESYSROOT}/usr/include/${f}" "zstd/${f}" || die
+ done
+ sed -i -e '/include_dirs/a libraries=["zstd"],' make_cffi.py || die
+
+ distutils-r1_src_prepare
+
+ DISTUTILS_ARGS=(
+ --no-c-backend
+ )
+}
+
+python_test() {
+ local EPYTEST_DESELECT=(
+ # unreliable, fails on x86
+ tests/test_data_structures.py::TestCompressionParameters::test_estimated_compression_context_size
+ # check for bundled zstd version, fails on other system zstd
+ tests/test_module_attributes.py::TestModuleAttributes::test_version
+ )
+
+ rm -rf zstandard || die
+ epytest
+}