brotli-rs 9.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- brotli_rs-9.0.0/.gitattributes +4 -0
- brotli_rs-9.0.0/.github/workflows/ci.yml +65 -0
- brotli_rs-9.0.0/.github/workflows/release.yml +156 -0
- brotli_rs-9.0.0/.gitignore +8 -0
- brotli_rs-9.0.0/Cargo.lock +170 -0
- brotli_rs-9.0.0/Cargo.toml +21 -0
- brotli_rs-9.0.0/LICENSE +22 -0
- brotli_rs-9.0.0/PKG-INFO +138 -0
- brotli_rs-9.0.0/README.md +75 -0
- brotli_rs-9.0.0/RELEASING.md +61 -0
- brotli_rs-9.0.0/SECURITY.md +7 -0
- brotli_rs-9.0.0/licenses/README.md +13 -0
- brotli_rs-9.0.0/licenses/alloc-no-stdlib-3.0.0/LICENSE +12 -0
- brotli_rs-9.0.0/licenses/alloc-stdlib-0.3.0/LICENSE +12 -0
- brotli_rs-9.0.0/licenses/brotli-9.0.0/LICENSE.BSD-3-Clause +12 -0
- brotli_rs-9.0.0/licenses/brotli-9.0.0/LICENSE.MIT +19 -0
- brotli_rs-9.0.0/licenses/brotli-decompressor-6.0.1/LICENSE +12 -0
- brotli_rs-9.0.0/licenses/heck-0.5.0/LICENSE-APACHE +201 -0
- brotli_rs-9.0.0/licenses/heck-0.5.0/LICENSE-MIT +25 -0
- brotli_rs-9.0.0/licenses/libc-0.2.191/LICENSE-APACHE +176 -0
- brotli_rs-9.0.0/licenses/libc-0.2.191/LICENSE-MIT +25 -0
- brotli_rs-9.0.0/licenses/once_cell-1.21.4/LICENSE-APACHE +201 -0
- brotli_rs-9.0.0/licenses/once_cell-1.21.4/LICENSE-MIT +23 -0
- brotli_rs-9.0.0/licenses/portable-atomic-1.15.0/LICENSE-APACHE +177 -0
- brotli_rs-9.0.0/licenses/portable-atomic-1.15.0/LICENSE-MIT +23 -0
- brotli_rs-9.0.0/licenses/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
- brotli_rs-9.0.0/licenses/proc-macro2-1.0.107/LICENSE-MIT +23 -0
- brotli_rs-9.0.0/licenses/pyo3-0.30.1/LICENSE-APACHE +178 -0
- brotli_rs-9.0.0/licenses/pyo3-0.30.1/LICENSE-MIT +25 -0
- brotli_rs-9.0.0/licenses/pyo3-build-config-0.30.1/LICENSE-APACHE +178 -0
- brotli_rs-9.0.0/licenses/pyo3-build-config-0.30.1/LICENSE-MIT +25 -0
- brotli_rs-9.0.0/licenses/pyo3-ffi-0.30.1/LICENSE-APACHE +178 -0
- brotli_rs-9.0.0/licenses/pyo3-ffi-0.30.1/LICENSE-MIT +25 -0
- brotli_rs-9.0.0/licenses/pyo3-macros-0.30.1/LICENSE-APACHE +178 -0
- brotli_rs-9.0.0/licenses/pyo3-macros-0.30.1/LICENSE-MIT +25 -0
- brotli_rs-9.0.0/licenses/pyo3-macros-backend-0.30.1/LICENSE-APACHE +178 -0
- brotli_rs-9.0.0/licenses/pyo3-macros-backend-0.30.1/LICENSE-MIT +25 -0
- brotli_rs-9.0.0/licenses/quote-1.0.47/LICENSE-APACHE +176 -0
- brotli_rs-9.0.0/licenses/quote-1.0.47/LICENSE-MIT +23 -0
- brotli_rs-9.0.0/licenses/syn-3.0.9/LICENSE-APACHE +176 -0
- brotli_rs-9.0.0/licenses/syn-3.0.9/LICENSE-MIT +23 -0
- brotli_rs-9.0.0/licenses/target-lexicon-0.13.5/LICENSE +220 -0
- brotli_rs-9.0.0/licenses/unicode-ident-1.0.27/LICENSE-APACHE +176 -0
- brotli_rs-9.0.0/licenses/unicode-ident-1.0.27/LICENSE-MIT +23 -0
- brotli_rs-9.0.0/licenses/unicode-ident-1.0.27/LICENSE-UNICODE +39 -0
- brotli_rs-9.0.0/pyproject.toml +47 -0
- brotli_rs-9.0.0/python/brotli_rs/__init__.py +155 -0
- brotli_rs-9.0.0/python/brotli_rs/__init__.pyi +47 -0
- brotli_rs-9.0.0/python/brotli_rs/py.typed +1 -0
- brotli_rs-9.0.0/src/lib.rs +273 -0
- brotli_rs-9.0.0/tests/__init__.py +1 -0
- brotli_rs-9.0.0/tests/project/test_api.py +73 -0
- brotli_rs-9.0.0/tests/project/test_interoperability.py +22 -0
- brotli_rs-9.0.0/tests/project/test_streaming.py +96 -0
- brotli_rs-9.0.0/tests/upstream/README.md +21 -0
- brotli_rs-9.0.0/tests/upstream/__init__.py +1 -0
- brotli_rs-9.0.0/tests/upstream/archivey/LICENSE +21 -0
- brotli_rs-9.0.0/tests/upstream/archivey/SOURCE.md +13 -0
- brotli_rs-9.0.0/tests/upstream/archivey/test_malformed_streams.py +73 -0
- brotli_rs-9.0.0/tests/upstream/brotlicffi/LICENSE +19 -0
- brotli_rs-9.0.0/tests/upstream/brotlicffi/SOURCE.md +17 -0
- brotli_rs-9.0.0/tests/upstream/brotlicffi/test_streaming_semantics.py +116 -0
- brotli_rs-9.0.0/tests/upstream/dropbox_rust_brotli/LICENSE.BSD-3-Clause +12 -0
- brotli_rs-9.0.0/tests/upstream/dropbox_rust_brotli/LICENSE.MIT +19 -0
- brotli_rs-9.0.0/tests/upstream/dropbox_rust_brotli/SOURCE.md +14 -0
- brotli_rs-9.0.0/tests/upstream/dropbox_rust_brotli/test_encoder_vectors.py +34 -0
- brotli_rs-9.0.0/tests/upstream/dropbox_rust_brotli/testdata/aaabaaaa +1 -0
- brotli_rs-9.0.0/tests/upstream/dropbox_rust_brotli/testdata/ends_with_truncated_dictionary +1 -0
- brotli_rs-9.0.0/tests/upstream/dropbox_rust_brotli/testdata/random_then_unicode +0 -0
- brotli_rs-9.0.0/tests/upstream/encode_httpx/LICENSE +12 -0
- brotli_rs-9.0.0/tests/upstream/encode_httpx/SOURCE.md +11 -0
- brotli_rs-9.0.0/tests/upstream/encode_httpx/test_decoder_cases.py +31 -0
- brotli_rs-9.0.0/tests/upstream/getsentry_sentry_python/LICENSE +21 -0
- brotli_rs-9.0.0/tests/upstream/getsentry_sentry_python/SOURCE.md +11 -0
- brotli_rs-9.0.0/tests/upstream/getsentry_sentry_python/test_transport_payload.py +18 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/LICENSE +19 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/SOURCE.md +23 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/__init__.py +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/_test_utils.py +154 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/synth_test.go +2295 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/test_compress.py +41 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/test_compressor.py +100 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/test_decompress.py +43 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/test_decompressor.py +118 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/test_synth_vectors.py +89 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/10x10y +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/10x10y.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/64x +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/64x.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/alice29.txt +3609 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/alice29.txt.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/asyoulik.txt +4122 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/asyoulik.txt.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/backward65536 +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/backward65536.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/compressed_file +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/compressed_file.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/compressed_repeated +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/compressed_repeated.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/cp1251-utf16le +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/cp1251-utf16le.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/cp852-utf8 +12 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/cp852-utf8.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.00 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.01 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.02 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.03 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.04 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.05 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.06 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.07 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.08 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.09 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.10 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.11 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.12 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.13 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.14 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.15 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.16 +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.17 +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/empty.compressed.18 +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/lcet10.txt +7519 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/lcet10.txt.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/mapsdatazrh +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/mapsdatazrh.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/monkey +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/monkey.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/plrabn12.txt +10699 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/plrabn12.txt.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/quickfox +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/quickfox.compressed +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/quickfox_repeated +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/quickfox_repeated.compressed +2 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/random_chunks +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/random_org_10k.bin +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/random_org_10k.bin.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/ukkonooa +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/ukkonooa.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/x +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/x.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/x.compressed.00 +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/x.compressed.01 +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/x.compressed.02 +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/x.compressed.03 +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/xyzzy +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/xyzzy.compressed +1 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/zeros +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/zeros.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/zerosukkanooa +0 -0
- brotli_rs-9.0.0/tests/upstream/google_brotli/testdata/zerosukkanooa.compressed +0 -0
- brotli_rs-9.0.0/tests/upstream/kagisearch_fastfeedparser/LICENSE +21 -0
- brotli_rs-9.0.0/tests/upstream/kagisearch_fastfeedparser/SOURCE.md +14 -0
- brotli_rs-9.0.0/tests/upstream/kagisearch_fastfeedparser/test_output_limits.py +26 -0
- brotli_rs-9.0.0/tests/upstream/lee101_mojo_brotli/LICENSE +21 -0
- brotli_rs-9.0.0/tests/upstream/lee101_mojo_brotli/SOURCE.md +17 -0
- brotli_rs-9.0.0/tests/upstream/lee101_mojo_brotli/test_binding_boundaries.py +83 -0
- brotli_rs-9.0.0/tests/upstream/urllib3/LICENSE +21 -0
- brotli_rs-9.0.0/tests/upstream/urllib3/SOURCE.md +13 -0
- brotli_rs-9.0.0/tests/upstream/urllib3/test_bounded_streaming.py +47 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
name: Python ${{ matrix.python }} on ${{ matrix.os }}
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
include:
|
|
20
|
+
- os: ubuntu-latest
|
|
21
|
+
python: "3.11"
|
|
22
|
+
- os: ubuntu-latest
|
|
23
|
+
python: "3.12"
|
|
24
|
+
- os: ubuntu-latest
|
|
25
|
+
python: "3.13"
|
|
26
|
+
- os: ubuntu-latest
|
|
27
|
+
python: "3.14"
|
|
28
|
+
- os: ubuntu-latest
|
|
29
|
+
python: "3.15"
|
|
30
|
+
- os: macos-latest
|
|
31
|
+
python: "3.12"
|
|
32
|
+
- os: windows-latest
|
|
33
|
+
python: "3.12"
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v6
|
|
36
|
+
- uses: actions/setup-python@v6
|
|
37
|
+
with:
|
|
38
|
+
python-version: ${{ matrix.python }}
|
|
39
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
40
|
+
- name: Install test tools
|
|
41
|
+
run: python -m pip install maturin pytest hypothesis "Brotli==1.2.1"
|
|
42
|
+
- name: Build wheel
|
|
43
|
+
run: maturin build --release --locked --out dist
|
|
44
|
+
- name: Install wheel
|
|
45
|
+
run: python -m pip install --no-index --find-links=dist --force-reinstall brotli-rs
|
|
46
|
+
- name: Test
|
|
47
|
+
run: pytest
|
|
48
|
+
|
|
49
|
+
rust:
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v6
|
|
53
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
54
|
+
with:
|
|
55
|
+
components: clippy, rustfmt
|
|
56
|
+
- run: cargo fmt --check
|
|
57
|
+
- run: cargo clippy --locked --all-targets -- -D warnings
|
|
58
|
+
|
|
59
|
+
minimum-rust:
|
|
60
|
+
runs-on: ubuntu-latest
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v6
|
|
63
|
+
- uses: dtolnay/rust-toolchain@1.85
|
|
64
|
+
- run: cargo check --locked
|
|
65
|
+
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
version:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v6
|
|
15
|
+
- name: Match tag to package version
|
|
16
|
+
env:
|
|
17
|
+
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
18
|
+
run: |
|
|
19
|
+
python - <<'PY'
|
|
20
|
+
import os
|
|
21
|
+
import tomllib
|
|
22
|
+
|
|
23
|
+
with open("pyproject.toml", "rb") as file:
|
|
24
|
+
version = tomllib.load(file)["project"]["version"]
|
|
25
|
+
expected = f"v{version}"
|
|
26
|
+
actual = os.environ["RELEASE_TAG"]
|
|
27
|
+
if actual != expected:
|
|
28
|
+
raise SystemExit(f"release tag {actual!r} must be {expected!r}")
|
|
29
|
+
PY
|
|
30
|
+
|
|
31
|
+
linux:
|
|
32
|
+
needs: version
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
strategy:
|
|
35
|
+
fail-fast: false
|
|
36
|
+
matrix:
|
|
37
|
+
target: [x86_64, aarch64]
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v6
|
|
40
|
+
- uses: actions/setup-python@v6
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.11"
|
|
43
|
+
- uses: PyO3/maturin-action@v1
|
|
44
|
+
with:
|
|
45
|
+
target: ${{ matrix.target }}
|
|
46
|
+
args: --release --locked --out dist
|
|
47
|
+
manylinux: auto
|
|
48
|
+
- uses: actions/upload-artifact@v6
|
|
49
|
+
with:
|
|
50
|
+
name: wheels-linux-${{ matrix.target }}
|
|
51
|
+
path: dist
|
|
52
|
+
|
|
53
|
+
musllinux:
|
|
54
|
+
needs: version
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
strategy:
|
|
57
|
+
fail-fast: false
|
|
58
|
+
matrix:
|
|
59
|
+
target: [x86_64, aarch64]
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v6
|
|
62
|
+
- uses: actions/setup-python@v6
|
|
63
|
+
with:
|
|
64
|
+
python-version: "3.11"
|
|
65
|
+
- uses: PyO3/maturin-action@v1
|
|
66
|
+
with:
|
|
67
|
+
target: ${{ matrix.target }}
|
|
68
|
+
args: --release --locked --out dist
|
|
69
|
+
manylinux: musllinux_1_2
|
|
70
|
+
- uses: actions/upload-artifact@v6
|
|
71
|
+
with:
|
|
72
|
+
name: wheels-musllinux-${{ matrix.target }}
|
|
73
|
+
path: dist
|
|
74
|
+
|
|
75
|
+
windows:
|
|
76
|
+
needs: version
|
|
77
|
+
runs-on: ${{ matrix.runner }}
|
|
78
|
+
strategy:
|
|
79
|
+
fail-fast: false
|
|
80
|
+
matrix:
|
|
81
|
+
include:
|
|
82
|
+
- runner: windows-latest
|
|
83
|
+
target: x64
|
|
84
|
+
python_architecture: x64
|
|
85
|
+
- runner: windows-11-arm
|
|
86
|
+
target: aarch64
|
|
87
|
+
python_architecture: arm64
|
|
88
|
+
steps:
|
|
89
|
+
- uses: actions/checkout@v6
|
|
90
|
+
- uses: actions/setup-python@v6
|
|
91
|
+
with:
|
|
92
|
+
python-version: "3.13"
|
|
93
|
+
architecture: ${{ matrix.python_architecture }}
|
|
94
|
+
- uses: PyO3/maturin-action@v1
|
|
95
|
+
with:
|
|
96
|
+
target: ${{ matrix.target }}
|
|
97
|
+
args: --release --locked --out dist
|
|
98
|
+
- uses: actions/upload-artifact@v6
|
|
99
|
+
with:
|
|
100
|
+
name: wheels-windows-${{ matrix.target }}
|
|
101
|
+
path: dist
|
|
102
|
+
|
|
103
|
+
macos:
|
|
104
|
+
needs: version
|
|
105
|
+
runs-on: ${{ matrix.runner }}
|
|
106
|
+
strategy:
|
|
107
|
+
fail-fast: false
|
|
108
|
+
matrix:
|
|
109
|
+
include:
|
|
110
|
+
- runner: macos-15-intel
|
|
111
|
+
target: x86_64
|
|
112
|
+
- runner: macos-latest
|
|
113
|
+
target: aarch64
|
|
114
|
+
steps:
|
|
115
|
+
- uses: actions/checkout@v6
|
|
116
|
+
- uses: actions/setup-python@v6
|
|
117
|
+
with:
|
|
118
|
+
python-version: "3.11"
|
|
119
|
+
- uses: PyO3/maturin-action@v1
|
|
120
|
+
with:
|
|
121
|
+
target: ${{ matrix.target }}
|
|
122
|
+
args: --release --locked --out dist
|
|
123
|
+
- uses: actions/upload-artifact@v6
|
|
124
|
+
with:
|
|
125
|
+
name: wheels-macos-${{ matrix.target }}
|
|
126
|
+
path: dist
|
|
127
|
+
|
|
128
|
+
sdist:
|
|
129
|
+
needs: version
|
|
130
|
+
runs-on: ubuntu-latest
|
|
131
|
+
steps:
|
|
132
|
+
- uses: actions/checkout@v6
|
|
133
|
+
- uses: PyO3/maturin-action@v1
|
|
134
|
+
with:
|
|
135
|
+
command: sdist
|
|
136
|
+
args: --out dist
|
|
137
|
+
- uses: actions/upload-artifact@v6
|
|
138
|
+
with:
|
|
139
|
+
name: sdist
|
|
140
|
+
path: dist
|
|
141
|
+
|
|
142
|
+
publish:
|
|
143
|
+
runs-on: ubuntu-latest
|
|
144
|
+
needs: [linux, musllinux, windows, macos, sdist]
|
|
145
|
+
environment: pypi
|
|
146
|
+
permissions:
|
|
147
|
+
id-token: write
|
|
148
|
+
steps:
|
|
149
|
+
- uses: actions/download-artifact@v7
|
|
150
|
+
with:
|
|
151
|
+
path: dist
|
|
152
|
+
merge-multiple: true
|
|
153
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
154
|
+
with:
|
|
155
|
+
packages-dir: dist
|
|
156
|
+
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 3
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "alloc-no-stdlib"
|
|
7
|
+
version = "3.0.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c2fb6cfd47bf496ff64095c20eaba0c201404ee38714d4142fcfa1dc334fcc7a"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "alloc-stdlib"
|
|
13
|
+
version = "0.3.0"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "0b5c1865780388bfa186411ab5f247819487fc4864c6e9c3106611fa347586e1"
|
|
16
|
+
dependencies = [
|
|
17
|
+
"alloc-no-stdlib",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[[package]]
|
|
21
|
+
name = "brotli"
|
|
22
|
+
version = "9.0.0"
|
|
23
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
+
checksum = "f8b851b75c23ca7873623d612fe49bd1989aeb03d08fb9432187eb253d3d4c6b"
|
|
25
|
+
dependencies = [
|
|
26
|
+
"alloc-no-stdlib",
|
|
27
|
+
"alloc-stdlib",
|
|
28
|
+
"brotli-decompressor",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[[package]]
|
|
32
|
+
name = "brotli-decompressor"
|
|
33
|
+
version = "6.0.1"
|
|
34
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
35
|
+
checksum = "941cd9bd4ddab83cb46fa5a2d428f1c857b24ac78cb876cf7beb710840934bd7"
|
|
36
|
+
dependencies = [
|
|
37
|
+
"alloc-no-stdlib",
|
|
38
|
+
"alloc-stdlib",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[[package]]
|
|
42
|
+
name = "brotli-rs-python"
|
|
43
|
+
version = "9.0.0"
|
|
44
|
+
dependencies = [
|
|
45
|
+
"brotli",
|
|
46
|
+
"brotli-decompressor",
|
|
47
|
+
"pyo3",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[[package]]
|
|
51
|
+
name = "heck"
|
|
52
|
+
version = "0.5.0"
|
|
53
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
54
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
55
|
+
|
|
56
|
+
[[package]]
|
|
57
|
+
name = "libc"
|
|
58
|
+
version = "0.2.191"
|
|
59
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
60
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
61
|
+
|
|
62
|
+
[[package]]
|
|
63
|
+
name = "once_cell"
|
|
64
|
+
version = "1.21.4"
|
|
65
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
66
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
67
|
+
|
|
68
|
+
[[package]]
|
|
69
|
+
name = "portable-atomic"
|
|
70
|
+
version = "1.15.0"
|
|
71
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
72
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
73
|
+
|
|
74
|
+
[[package]]
|
|
75
|
+
name = "proc-macro2"
|
|
76
|
+
version = "1.0.107"
|
|
77
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
78
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
79
|
+
dependencies = [
|
|
80
|
+
"unicode-ident",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[[package]]
|
|
84
|
+
name = "pyo3"
|
|
85
|
+
version = "0.30.1"
|
|
86
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
88
|
+
dependencies = [
|
|
89
|
+
"libc",
|
|
90
|
+
"once_cell",
|
|
91
|
+
"portable-atomic",
|
|
92
|
+
"pyo3-build-config",
|
|
93
|
+
"pyo3-ffi",
|
|
94
|
+
"pyo3-macros",
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
[[package]]
|
|
98
|
+
name = "pyo3-build-config"
|
|
99
|
+
version = "0.30.1"
|
|
100
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
101
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
102
|
+
dependencies = [
|
|
103
|
+
"target-lexicon",
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
[[package]]
|
|
107
|
+
name = "pyo3-ffi"
|
|
108
|
+
version = "0.30.1"
|
|
109
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
110
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
111
|
+
dependencies = [
|
|
112
|
+
"libc",
|
|
113
|
+
"pyo3-build-config",
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
[[package]]
|
|
117
|
+
name = "pyo3-macros"
|
|
118
|
+
version = "0.30.1"
|
|
119
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
120
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
121
|
+
dependencies = [
|
|
122
|
+
"proc-macro2",
|
|
123
|
+
"pyo3-macros-backend",
|
|
124
|
+
"quote",
|
|
125
|
+
"syn",
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
[[package]]
|
|
129
|
+
name = "pyo3-macros-backend"
|
|
130
|
+
version = "0.30.1"
|
|
131
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
132
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
133
|
+
dependencies = [
|
|
134
|
+
"heck",
|
|
135
|
+
"proc-macro2",
|
|
136
|
+
"quote",
|
|
137
|
+
"syn",
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
[[package]]
|
|
141
|
+
name = "quote"
|
|
142
|
+
version = "1.0.47"
|
|
143
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
144
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
145
|
+
dependencies = [
|
|
146
|
+
"proc-macro2",
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
[[package]]
|
|
150
|
+
name = "syn"
|
|
151
|
+
version = "3.0.9"
|
|
152
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
153
|
+
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
|
154
|
+
dependencies = [
|
|
155
|
+
"proc-macro2",
|
|
156
|
+
"quote",
|
|
157
|
+
"unicode-ident",
|
|
158
|
+
]
|
|
159
|
+
|
|
160
|
+
[[package]]
|
|
161
|
+
name = "target-lexicon"
|
|
162
|
+
version = "0.13.5"
|
|
163
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
164
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
165
|
+
|
|
166
|
+
[[package]]
|
|
167
|
+
name = "unicode-ident"
|
|
168
|
+
version = "1.0.27"
|
|
169
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
170
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "brotli-rs-python"
|
|
3
|
+
version = "9.0.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
rust-version = "1.85"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
description = "Python bindings for the safe-Rust brotli crate"
|
|
8
|
+
repository = "https://github.com/bugsink/brotli-rs"
|
|
9
|
+
homepage = "https://github.com/bugsink/brotli-rs"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
publish = false
|
|
12
|
+
|
|
13
|
+
[lib]
|
|
14
|
+
name = "_brotli_rs"
|
|
15
|
+
crate-type = ["cdylib"]
|
|
16
|
+
|
|
17
|
+
[dependencies]
|
|
18
|
+
brotli = "=9.0.0"
|
|
19
|
+
brotli-decompressor = "=6.0.1"
|
|
20
|
+
pyo3 = { version = "0.30.1", features = ["abi3-py311", "extension-module"] }
|
|
21
|
+
|
brotli_rs-9.0.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bugsink
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
brotli_rs-9.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: brotli-rs
|
|
3
|
+
Version: 9.0.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Programming Language :: Python
|
|
6
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
12
|
+
Classifier: Programming Language :: Rust
|
|
13
|
+
Classifier: Topic :: System :: Archiving :: Compression
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Requires-Dist: brotli==1.2.1 ; extra == 'test'
|
|
16
|
+
Requires-Dist: hypothesis>=6 ; extra == 'test'
|
|
17
|
+
Requires-Dist: pytest>=8 ; extra == 'test'
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
License-File: licenses/README.md
|
|
21
|
+
License-File: licenses/alloc-no-stdlib-3.0.0/LICENSE
|
|
22
|
+
License-File: licenses/alloc-stdlib-0.3.0/LICENSE
|
|
23
|
+
License-File: licenses/brotli-9.0.0/LICENSE.BSD-3-Clause
|
|
24
|
+
License-File: licenses/brotli-9.0.0/LICENSE.MIT
|
|
25
|
+
License-File: licenses/brotli-decompressor-6.0.1/LICENSE
|
|
26
|
+
License-File: licenses/heck-0.5.0/LICENSE-APACHE
|
|
27
|
+
License-File: licenses/heck-0.5.0/LICENSE-MIT
|
|
28
|
+
License-File: licenses/libc-0.2.191/LICENSE-APACHE
|
|
29
|
+
License-File: licenses/libc-0.2.191/LICENSE-MIT
|
|
30
|
+
License-File: licenses/once_cell-1.21.4/LICENSE-APACHE
|
|
31
|
+
License-File: licenses/once_cell-1.21.4/LICENSE-MIT
|
|
32
|
+
License-File: licenses/portable-atomic-1.15.0/LICENSE-APACHE
|
|
33
|
+
License-File: licenses/portable-atomic-1.15.0/LICENSE-MIT
|
|
34
|
+
License-File: licenses/proc-macro2-1.0.107/LICENSE-APACHE
|
|
35
|
+
License-File: licenses/proc-macro2-1.0.107/LICENSE-MIT
|
|
36
|
+
License-File: licenses/pyo3-0.30.1/LICENSE-APACHE
|
|
37
|
+
License-File: licenses/pyo3-0.30.1/LICENSE-MIT
|
|
38
|
+
License-File: licenses/pyo3-build-config-0.30.1/LICENSE-APACHE
|
|
39
|
+
License-File: licenses/pyo3-build-config-0.30.1/LICENSE-MIT
|
|
40
|
+
License-File: licenses/pyo3-ffi-0.30.1/LICENSE-APACHE
|
|
41
|
+
License-File: licenses/pyo3-ffi-0.30.1/LICENSE-MIT
|
|
42
|
+
License-File: licenses/pyo3-macros-0.30.1/LICENSE-APACHE
|
|
43
|
+
License-File: licenses/pyo3-macros-0.30.1/LICENSE-MIT
|
|
44
|
+
License-File: licenses/pyo3-macros-backend-0.30.1/LICENSE-APACHE
|
|
45
|
+
License-File: licenses/pyo3-macros-backend-0.30.1/LICENSE-MIT
|
|
46
|
+
License-File: licenses/quote-1.0.47/LICENSE-APACHE
|
|
47
|
+
License-File: licenses/quote-1.0.47/LICENSE-MIT
|
|
48
|
+
License-File: licenses/syn-3.0.9/LICENSE-APACHE
|
|
49
|
+
License-File: licenses/syn-3.0.9/LICENSE-MIT
|
|
50
|
+
License-File: licenses/target-lexicon-0.13.5/LICENSE
|
|
51
|
+
License-File: licenses/unicode-ident-1.0.27/LICENSE-APACHE
|
|
52
|
+
License-File: licenses/unicode-ident-1.0.27/LICENSE-MIT
|
|
53
|
+
License-File: licenses/unicode-ident-1.0.27/LICENSE-UNICODE
|
|
54
|
+
Summary: Python bindings for the safe-Rust brotli crate
|
|
55
|
+
Keywords: brotli,compression,rust
|
|
56
|
+
Home-Page: https://github.com/bugsink/brotli-rs
|
|
57
|
+
License-Expression: MIT
|
|
58
|
+
Requires-Python: >=3.11
|
|
59
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
60
|
+
Project-URL: Issues, https://github.com/bugsink/brotli-rs/issues
|
|
61
|
+
Project-URL: Source, https://github.com/bugsink/brotli-rs
|
|
62
|
+
|
|
63
|
+
# brotli-rs
|
|
64
|
+
|
|
65
|
+
Python bindings for Dropbox's safe-Rust
|
|
66
|
+
[`brotli`](https://github.com/dropbox/rust-brotli) crate.
|
|
67
|
+
|
|
68
|
+
The public API follows the `Brotli` Python package where that can be done
|
|
69
|
+
without inheriting its C extension. The distribution and import names are
|
|
70
|
+
both `brotli-rs` / `brotli_rs`, deliberately avoiding a collision with the
|
|
71
|
+
existing `brotli` module.
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import brotli_rs as brotli
|
|
75
|
+
|
|
76
|
+
compressed = brotli.compress(b"hello")
|
|
77
|
+
assert brotli.decompress(compressed) == b"hello"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Streaming compression and decompression are available through `Compressor`
|
|
81
|
+
and `Decompressor`. `Decompressor.process()` supports a strict
|
|
82
|
+
`output_buffer_limit`, and both streaming and one-shot decompression accept an
|
|
83
|
+
optional `max_output` limit.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
decoder = brotli.Decompressor(max_output=16 * 1024 * 1024)
|
|
87
|
+
parts = []
|
|
88
|
+
for compressed_chunk in source:
|
|
89
|
+
while not decoder.is_finished() and not decoder.can_accept_more_data():
|
|
90
|
+
parts.append(decoder.process(b"", output_buffer_limit=64 * 1024))
|
|
91
|
+
parts.append(decoder.process(compressed_chunk, output_buffer_limit=64 * 1024))
|
|
92
|
+
while not decoder.is_finished() and not decoder.can_accept_more_data():
|
|
93
|
+
parts.append(decoder.process(b"", output_buffer_limit=64 * 1024))
|
|
94
|
+
if not decoder.is_finished():
|
|
95
|
+
raise brotli.error("incomplete stream")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The compatibility surface consists of `compress`, `decompress`,
|
|
99
|
+
`Compressor.process()` / `.flush()` / `.finish()`,
|
|
100
|
+
`Decompressor.process()` / `.can_accept_more_data()` / `.is_finished()`, the
|
|
101
|
+
three `MODE_*` constants, `error`, `version`, and `__version__`. Contiguous
|
|
102
|
+
buffer-protocol inputs are accepted. `version` is a string alias of
|
|
103
|
+
`__version__`, as it is in the current `Brotli` package.
|
|
104
|
+
|
|
105
|
+
Compressed bytes are not promised to be byte-identical to Google's encoder.
|
|
106
|
+
They are Brotli-compatible streams, tested in both directions against Google
|
|
107
|
+
Brotli 1.2.1. Exception text, subclassing, pickling, non-contiguous buffers,
|
|
108
|
+
and private implementation names are outside the compatibility contract.
|
|
109
|
+
|
|
110
|
+
The base package version tracks the Rust `brotli` crate exactly.
|
|
111
|
+
Python-binding-only fixes use PEP 440 post releases, such as `9.0.0.post1`,
|
|
112
|
+
while still pinning `brotli = 9.0.0`.
|
|
113
|
+
|
|
114
|
+
## Why?
|
|
115
|
+
|
|
116
|
+
What do you think is more secure? World class engineers working at one of
|
|
117
|
+
the world's largest tech companies trying to juggle chainsaws in their spare
|
|
118
|
+
time, or an entirely vibe-coded wrapper in a memory-safe language with a Rust
|
|
119
|
+
crate on the inside?
|
|
120
|
+
|
|
121
|
+
If you bet on the latter, you've come to the right place.
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
Install Rust and Python 3.11 or newer, then:
|
|
126
|
+
|
|
127
|
+
```console
|
|
128
|
+
python -m venv .venv
|
|
129
|
+
. .venv/bin/activate
|
|
130
|
+
python -m pip install maturin
|
|
131
|
+
maturin develop --extras=test
|
|
132
|
+
pytest
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
See `tests/upstream/README.md` for the provenance of imported and adapted
|
|
136
|
+
upstream tests.
|
|
137
|
+
|
|
138
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# brotli-rs
|
|
2
|
+
|
|
3
|
+
Python bindings for Dropbox's safe-Rust
|
|
4
|
+
[`brotli`](https://github.com/dropbox/rust-brotli) crate.
|
|
5
|
+
|
|
6
|
+
The public API follows the `Brotli` Python package where that can be done
|
|
7
|
+
without inheriting its C extension. The distribution and import names are
|
|
8
|
+
both `brotli-rs` / `brotli_rs`, deliberately avoiding a collision with the
|
|
9
|
+
existing `brotli` module.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
import brotli_rs as brotli
|
|
13
|
+
|
|
14
|
+
compressed = brotli.compress(b"hello")
|
|
15
|
+
assert brotli.decompress(compressed) == b"hello"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Streaming compression and decompression are available through `Compressor`
|
|
19
|
+
and `Decompressor`. `Decompressor.process()` supports a strict
|
|
20
|
+
`output_buffer_limit`, and both streaming and one-shot decompression accept an
|
|
21
|
+
optional `max_output` limit.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
decoder = brotli.Decompressor(max_output=16 * 1024 * 1024)
|
|
25
|
+
parts = []
|
|
26
|
+
for compressed_chunk in source:
|
|
27
|
+
while not decoder.is_finished() and not decoder.can_accept_more_data():
|
|
28
|
+
parts.append(decoder.process(b"", output_buffer_limit=64 * 1024))
|
|
29
|
+
parts.append(decoder.process(compressed_chunk, output_buffer_limit=64 * 1024))
|
|
30
|
+
while not decoder.is_finished() and not decoder.can_accept_more_data():
|
|
31
|
+
parts.append(decoder.process(b"", output_buffer_limit=64 * 1024))
|
|
32
|
+
if not decoder.is_finished():
|
|
33
|
+
raise brotli.error("incomplete stream")
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The compatibility surface consists of `compress`, `decompress`,
|
|
37
|
+
`Compressor.process()` / `.flush()` / `.finish()`,
|
|
38
|
+
`Decompressor.process()` / `.can_accept_more_data()` / `.is_finished()`, the
|
|
39
|
+
three `MODE_*` constants, `error`, `version`, and `__version__`. Contiguous
|
|
40
|
+
buffer-protocol inputs are accepted. `version` is a string alias of
|
|
41
|
+
`__version__`, as it is in the current `Brotli` package.
|
|
42
|
+
|
|
43
|
+
Compressed bytes are not promised to be byte-identical to Google's encoder.
|
|
44
|
+
They are Brotli-compatible streams, tested in both directions against Google
|
|
45
|
+
Brotli 1.2.1. Exception text, subclassing, pickling, non-contiguous buffers,
|
|
46
|
+
and private implementation names are outside the compatibility contract.
|
|
47
|
+
|
|
48
|
+
The base package version tracks the Rust `brotli` crate exactly.
|
|
49
|
+
Python-binding-only fixes use PEP 440 post releases, such as `9.0.0.post1`,
|
|
50
|
+
while still pinning `brotli = 9.0.0`.
|
|
51
|
+
|
|
52
|
+
## Why?
|
|
53
|
+
|
|
54
|
+
What do you think is more secure? World class engineers working at one of
|
|
55
|
+
the world's largest tech companies trying to juggle chainsaws in their spare
|
|
56
|
+
time, or an entirely vibe-coded wrapper in a memory-safe language with a Rust
|
|
57
|
+
crate on the inside?
|
|
58
|
+
|
|
59
|
+
If you bet on the latter, you've come to the right place.
|
|
60
|
+
|
|
61
|
+
## Development
|
|
62
|
+
|
|
63
|
+
Install Rust and Python 3.11 or newer, then:
|
|
64
|
+
|
|
65
|
+
```console
|
|
66
|
+
python -m venv .venv
|
|
67
|
+
. .venv/bin/activate
|
|
68
|
+
python -m pip install maturin
|
|
69
|
+
maturin develop --extras=test
|
|
70
|
+
pytest
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
See `tests/upstream/README.md` for the provenance of imported and adapted
|
|
74
|
+
upstream tests.
|
|
75
|
+
|