Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/brotlicffi/files/, dev-python/brotlicffi/
Date: Tue, 01 Dec 2020 10:32:13
Message-Id: 1606818721.4ca1a7d89e4de02f67458cfd955f40b658962437.mgorny@gentoo
1 commit: 4ca1a7d89e4de02f67458cfd955f40b658962437
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 1 09:53:02 2020 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 1 10:32:01 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4ca1a7d8
7
8 dev-python/brotlicffi: Incompatible rename of dev-python/brotlipy
9
10 This is the continuation of dev-python/brotlipy. I am not doing a move
11 here since the rename (obviously) breaks all reverse dependencies,
12 and both old and new names are co-installable. Good news is that this
13 removes the blocker on app-arch/brotli[python].
14
15 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
16
17 dev-python/brotlicffi/Manifest | 2 +
18 dev-python/brotlicffi/brotlicffi-0.8.0.ebuild | 52 ++++++++
19 .../files/brotlicffi-0.8.0-remove-dict.patch | 132 +++++++++++++++++++++
20 dev-python/brotlicffi/metadata.xml | 8 ++
21 4 files changed, 194 insertions(+)
22
23 diff --git a/dev-python/brotlicffi/Manifest b/dev-python/brotlicffi/Manifest
24 new file mode 100644
25 index 00000000000..66208cc556e
26 --- /dev/null
27 +++ b/dev-python/brotlicffi/Manifest
28 @@ -0,0 +1,2 @@
29 +DIST brotli-46c1a881b41bb638c76247558aa04b1591af3aa7.tar.gz 19840371 BLAKE2B b9a1c3c2e5b62bd63b392debe54bd1732ac1cb31f88500f0142108b453649d96901d9a03b6db98642cb9abaf9188c06d440f2b8bd3cf57fbbb52196a931f5079 SHA512 dc573c90491032a205f32f0ce9c93e95b06c70a3107caa9501e038a212226c37117d63709a29843367344bf7d18cf32d0c0578b11166387198e12b38b1522406
30 +DIST brotlicffi-0.8.0.gh.tar.gz 21997 BLAKE2B 5e817e228ce01cd7a831c59cca5bab3e851d676f1daa5efab8f61a203c0854bcc92605c88896dff5f4ce27fc880718da5ddfcf02a3bddbbd7b2e18c33f1e77a4 SHA512 fd0c64b400d3b48e0e2d113b4d75e32a2b33fd99505c7661d6d51ba9aedf5cc1f58be09bc90a5f1f7e3424addef2b54cc085a41e6291c87d53dd7d4e8fc7eb4e
31
32 diff --git a/dev-python/brotlicffi/brotlicffi-0.8.0.ebuild b/dev-python/brotlicffi/brotlicffi-0.8.0.ebuild
33 new file mode 100644
34 index 00000000000..a41420574ec
35 --- /dev/null
36 +++ b/dev-python/brotlicffi/brotlicffi-0.8.0.ebuild
37 @@ -0,0 +1,52 @@
38 +# Copyright 1999-2020 Gentoo Authors
39 +# Distributed under the terms of the GNU General Public License v2
40 +
41 +EAPI=7
42 +
43 +PYTHON_COMPAT=( python3_{6..9} pypy3 )
44 +
45 +inherit distutils-r1
46 +
47 +# Commit of the Brotli library bundled within brotlipy.
48 +BROTLI_BUNDLED_COMMIT="46c1a881b41bb638c76247558aa04b1591af3aa7"
49 +
50 +DESCRIPTION="Python binding to the Brotli library"
51 +HOMEPAGE="https://github.com/python-hyper/brotlipy/ https://pypi.python.org/pypi/brotlipy"
52 +SRC_URI="
53 + https://github.com/python-hyper/${PN}/archive/v${PV}.tar.gz
54 + -> ${P}.gh.tar.gz
55 + test? (
56 + https://github.com/google/brotli/archive/${BROTLI_BUNDLED_COMMIT}.tar.gz
57 + -> brotli-${BROTLI_BUNDLED_COMMIT}.tar.gz
58 + )"
59 +
60 +LICENSE="MIT"
61 +SLOT="0"
62 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x64-macos"
63 +
64 +RDEPEND="
65 + app-arch/brotli:=
66 + virtual/python-cffi[${PYTHON_USEDEP}]"
67 +DEPEND="
68 + test? (
69 + dev-python/hypothesis[${PYTHON_USEDEP}]
70 + )
71 +"
72 +
73 +distutils_enable_tests pytest
74 +
75 +PATCHES=(
76 + # remove custom dictionary code that isn't supported by new brotli
77 + "${FILESDIR}"/brotlicffi-0.8.0-remove-dict.patch
78 +)
79 +
80 +src_unpack() {
81 + default
82 + if use test; then
83 + mv "brotli-${BROTLI_BUNDLED_COMMIT}"/tests "${S}"/libbrotli/ || die
84 + fi
85 +}
86 +
87 +src_configure() {
88 + export USE_SHARED_BROTLI=1
89 +}
90
91 diff --git a/dev-python/brotlicffi/files/brotlicffi-0.8.0-remove-dict.patch b/dev-python/brotlicffi/files/brotlicffi-0.8.0-remove-dict.patch
92 new file mode 100644
93 index 00000000000..bfb1b61b951
94 --- /dev/null
95 +++ b/dev-python/brotlicffi/files/brotlicffi-0.8.0-remove-dict.patch
96 @@ -0,0 +1,132 @@
97 +From 0fe3dc70240ea62b56861ab830f9ab44644b18e5 Mon Sep 17 00:00:00 2001
98 +From: Seth Michael Larson <sethmichaellarson@×××××.com>
99 +Date: Sat, 28 Nov 2020 14:36:59 -0600
100 +Subject: [PATCH] Update libbrotli to 1.0.9
101 +
102 +(stripped down to removing custom dictionary support)
103 +
104 +---
105 + src/brotlicffi/_api.py | 21 ++----------
106 + src/brotlicffi/_build.py | 25 +-------------
107 + test/test_simple_compression.py | 8 -----
108 +
109 +diff --git a/src/brotlicffi/_api.py b/src/brotlicffi/_api.py
110 +index 49da0a3..8358d3f 100644
111 +--- a/src/brotlicffi/_api.py
112 ++++ b/src/brotlicffi/_api.py
113 +@@ -95,8 +95,7 @@ def compress(data,
114 + mode=DEFAULT_MODE,
115 + quality=lib.BROTLI_DEFAULT_QUALITY,
116 + lgwin=lib.BROTLI_DEFAULT_WINDOW,
117 +- lgblock=0,
118 +- dictionary=b''):
119 ++ lgblock=0):
120 + """
121 + Compress a string using Brotli.
122 +
123 +@@ -124,11 +123,6 @@ def compress(data,
124 + based on ``quality``.
125 + :type lgblock: ``int``
126 +
127 +- :param dictionary: A pre-set dictionary for LZ77. Please use this with
128 +- caution: if a dictionary is used for compression, the same dictionary
129 +- **must** be used for decompression!
130 +- :type dictionary: ``bytes``
131 +-
132 + :returns: The compressed bytestring.
133 + :rtype: ``bytes``
134 + """
135 +@@ -141,8 +135,7 @@ def compress(data,
136 + mode=mode,
137 + quality=quality,
138 + lgwin=lgwin,
139 +- lgblock=lgblock,
140 +- dictionary=dictionary
141 ++ lgblock=lgblock
142 + )
143 + compressed_data = compressor._compress(data, lib.BROTLI_OPERATION_FINISH)
144 + assert lib.BrotliEncoderIsFinished(compressor._encoder) == lib.BROTLI_TRUE
145 +@@ -255,8 +248,7 @@ def __init__(self,
146 + mode=DEFAULT_MODE,
147 + quality=lib.BROTLI_DEFAULT_QUALITY,
148 + lgwin=lib.BROTLI_DEFAULT_WINDOW,
149 +- lgblock=0,
150 +- dictionary=b''):
151 ++ lgblock=0):
152 + enc = lib.BrotliEncoderCreateInstance(
153 + ffi.NULL, ffi.NULL, ffi.NULL
154 + )
155 +@@ -271,13 +263,6 @@ def __init__(self,
156 + _set_parameter(enc, lib.BROTLI_PARAM_LGWIN, "lgwin", lgwin)
157 + _set_parameter(enc, lib.BROTLI_PARAM_LGBLOCK, "lgblock", lgblock)
158 +
159 +- if dictionary:
160 +- self._dictionary = ffi.new("uint8_t []", dictionary)
161 +- self._dictionary_size = len(dictionary)
162 +- lib.BrotliEncoderSetCustomDictionary(
163 +- enc, self._dictionary_size, self._dictionary
164 +- )
165 +-
166 + self._encoder = enc
167 +
168 + def _compress(self, data, operation):
169 +diff --git a/src/brotlicffi/_build.py b/src/brotlicffi/_build.py
170 +index d2a2d85..45dccb6 100644
171 +--- a/src/brotlicffi/_build.py
172 ++++ b/src/brotlicffi/_build.py
173 +@@ -93,20 +93,6 @@
174 + uint8_t** next_out,
175 + size_t* total_out);
176 +
177 +- /* Fills the new state with a dictionary for LZ77, warming up the
178 +- ringbuffer, e.g. for custom static dictionaries for data formats.
179 +- Not to be confused with the built-in transformable dictionary of Brotli.
180 +- |size| should be less or equal to 2^24 (16MiB), otherwise the dictionary
181 +- will be ignored. The dictionary must exist in memory until decoding is
182 +- done and is owned by the caller. To use:
183 +- 1) Allocate and initialize state with BrotliCreateInstance
184 +- 2) Use BrotliSetCustomDictionary
185 +- 3) Use BrotliDecompressStream
186 +- 4) Clean up and free state with BrotliDestroyState
187 +- */
188 +- void BrotliDecoderSetCustomDictionary(
189 +- BrotliDecoderState* s, size_t size, const uint8_t* dict);
190 +-
191 + /* Returns true, if decoder has some unconsumed output.
192 + Otherwise returns false. */
193 + BROTLI_BOOL BrotliDecoderHasMoreOutput(const BrotliDecoderState* s);
194 +@@ -205,15 +191,6 @@
195 + BrotliEncoderParameter p,
196 + uint32_t value);
197 +
198 +- /* Fills the new state with a dictionary for LZ77, warming up the
199 +- ringbuffer, e.g. for custom static dictionaries for data formats.
200 +- Not to be confused with the built-in transformable dictionary of Brotli.
201 +- To decode, use BrotliSetCustomDictionary() of the decoder with the same
202 +- dictionary. */
203 +- void BrotliEncoderSetCustomDictionary(BrotliEncoderState* state,
204 +- size_t size,
205 +- const uint8_t* dict);
206 +-
207 + /* Check if encoder is in "finished" state, i.e. no more input is
208 + acceptable and no more output will be produced.
209 + Works only with BrotliEncoderCompressStream workflow.
210 +diff --git a/test/test_simple_compression.py b/test/test_simple_compression.py
211 +index 45c322d..a480587 100644
212 +--- a/test/test_simple_compression.py
213 ++++ b/test/test_simple_compression.py
214 +@@ -110,14 +110,6 @@ def test_compressed_data_roundtrips(s):
215 + assert brotlicffi.decompress(brotlicffi.compress(s)) == s
216 +
217 +
218 +-@given(binary(), binary())
219 +-def test_compressed_data_with_dictionaries(s, dictionary):
220 +- d = brotlicffi.Decompressor(dictionary)
221 +- compressed = brotlicffi.compress(s, dictionary=dictionary)
222 +- uncompressed = d.decompress(compressed)
223 +- assert uncompressed == s
224 +-
225 +-
226 + @given(binary())
227 + def test_process_alias(s):
228 + c1 = brotlicffi.Compressor()
229
230 diff --git a/dev-python/brotlicffi/metadata.xml b/dev-python/brotlicffi/metadata.xml
231 new file mode 100644
232 index 00000000000..7f4f33c6dbc
233 --- /dev/null
234 +++ b/dev-python/brotlicffi/metadata.xml
235 @@ -0,0 +1,8 @@
236 +<?xml version="1.0" encoding="UTF-8"?>
237 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
238 +<pkgmetadata>
239 + <maintainer type="project">
240 + <email>python@g.o</email>
241 + <name>Python</name>
242 + </maintainer>
243 +</pkgmetadata>