Skip to content

Commit f5db265

Browse files
committed
refactor: use compression.zstd (PEP-784)
1 parent 1cca191 commit f5db265

40 files changed

+939
-9963
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -11,243 +11,88 @@ on:
1111
workflow_dispatch:
1212

1313
env:
14-
PYTHON_VER: "3.11" # Python to run test/cibuildwheel
15-
CIBW_BUILD: >
16-
cp310-* cp311-* cp312-* cp313-* cp313t-* cp314-* cp314t-*
17-
pp310-* pp311-*
18-
CIBW_ENABLE: cpython-freethreading pypy pypy-eol
19-
CIBW_TEST_COMMAND: python -m unittest discover {project}/tests
14+
PY_COLORS: 1
2015

2116
jobs:
22-
test_cpython:
23-
name: Test on ${{ matrix.platform }} ${{ matrix.architecture }} ${{ matrix.build_option }}
24-
runs-on: ${{ matrix.platform }}
25-
26-
strategy:
27-
matrix:
28-
platform:
29-
- ubuntu-latest
30-
- macos-latest
31-
- windows-latest
32-
build_option:
33-
- "--warning-as-error"
34-
- "--warning-as-error --multi-phase-init"
35-
- "--warning-as-error --cffi"
36-
architecture:
37-
- x64
38-
include:
39-
- platform: windows-latest
40-
build_option: "--warning-as-error"
41-
architecture: x86
42-
- platform: windows-latest
43-
build_option: "--warning-as-error --multi-phase-init"
44-
architecture: x86
45-
- platform: windows-latest
46-
build_option: "--warning-as-error --cffi"
47-
architecture: x86
48-
49-
steps:
50-
- uses: actions/checkout@v4
51-
with:
52-
submodules: true
53-
54-
- uses: actions/setup-python@v5
55-
with:
56-
python-version: ${{ env.PYTHON_VER }}
57-
architecture: ${{ matrix.architecture }}
58-
59-
- name: Run test
60-
run: |
61-
python -m pip install cffi
62-
python -m pip install --config-settings="--build-option=${{ matrix.build_option }}" -vv .
63-
python -m unittest discover tests
64-
65-
test_cpython_debug:
66-
name: Test debug build on Ubuntu ${{ matrix.build_option }}
67-
runs-on: ubuntu-latest
68-
69-
strategy:
70-
matrix:
71-
build_option:
72-
- "--warning-as-error --debug"
73-
- "--warning-as-error --debug --multi-phase-init"
74-
75-
steps:
76-
- uses: actions/checkout@v4
77-
with:
78-
submodules: true
79-
80-
- name: Run test
81-
run: |
82-
sudo apt-get update
83-
sudo apt-get install python3-dbg
84-
python3-dbg -m pip install --config-settings="--build-option=${{ matrix.build_option }}" -vv .
85-
python3-dbg -m unittest discover tests
86-
87-
test_pypy:
88-
name: Test on ${{ matrix.py }}
89-
runs-on: ubuntu-latest
90-
91-
strategy:
92-
matrix:
93-
py:
94-
- "pypy-3.10"
95-
- "pypy-3.11"
96-
97-
steps:
98-
- uses: actions/checkout@v4
99-
with:
100-
submodules: true
101-
102-
- uses: actions/setup-python@v5
103-
with:
104-
python-version: ${{ matrix.py }}
105-
106-
- name: Build & test
107-
run: |
108-
sudo apt-get install -q -y zstd libzstd1 libzstd-dev
109-
python -m pip install --config-settings="--build-option=--dynamic-link-zstd --warning-as-error" -v .
110-
python -m unittest discover tests
111-
112-
build_sdist:
113-
name: Build sdist
114-
if: startsWith(github.ref, 'refs/tags') || startsWith(github.head_ref, 'release-') || github.event_name == 'workflow_dispatch'
17+
build:
18+
name: Build
11519
runs-on: ubuntu-latest
116-
11720
steps:
118-
- uses: actions/checkout@v4
119-
with:
120-
submodules: true
121-
122-
- uses: actions/setup-python@v5
123-
with:
124-
python-version: ${{ env.PYTHON_VER }}
125-
126-
- name: Build sdist
127-
run: |
128-
python -m pip install -U build
129-
python -m build --sdist
130-
21+
- uses: actions/checkout@v6
22+
with:
23+
# fetch all commits for version computation
24+
fetch-depth: 0
25+
- name: Setup Python
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: "3.14"
29+
- name: Install dependencies
30+
run: python -m pip install -U build
31+
- name: Build
32+
run: python -m build
13133
- name: List distributions
13234
run: ls -lR dist
133-
134-
- name: Upload sdist
135-
uses: actions/upload-artifact@v4
136-
with:
137-
name: cibw-sdist
138-
path: dist/*.tar.gz
139-
140-
build_wheels:
141-
name: Build wheels on ${{ matrix.platform }}
142-
if: startsWith(github.ref, 'refs/tags') || startsWith(github.head_ref, 'release-') || github.event_name == 'workflow_dispatch'
143-
runs-on: ${{ matrix.platform }}
144-
145-
strategy:
146-
matrix:
147-
platform:
148-
- ubuntu-latest
149-
- macos-latest
150-
- windows-latest
151-
- windows-11-arm
152-
153-
env:
154-
CIBW_ARCHS_MACOS: "x86_64 arm64"
155-
156-
steps:
157-
- uses: actions/checkout@v4
158-
with:
159-
submodules: true
160-
161-
- uses: actions/setup-python@v5
162-
with:
163-
python-version: ${{ env.PYTHON_VER }}
164-
165-
- name: Build wheels
166-
run: |
167-
python -m pip install -U cibuildwheel
168-
python -m cibuildwheel --output-dir wheelhouse
169-
170-
- name: List distributions
171-
run: ls -lR wheelhouse
172-
shell: bash
173-
174-
- name: Upload wheels
175-
uses: actions/upload-artifact@v4
35+
- name: Save build artifacts
36+
uses: actions/upload-artifact@v5
17637
with:
177-
name: cibw-wheels-${{ matrix.platform }}
178-
path: wheelhouse/*.whl
38+
name: build
39+
path: dist
40+
- name: Install sdist
41+
run: python -m pip install dist/*.tar.gz
42+
- name: Test
43+
run: python -m unittest discover tests -v
17944

180-
build_arch_wheels:
181-
name: Build wheels for ${{ matrix.arch }} (skip ${{ matrix.skip_image }})
182-
if: startsWith(github.ref, 'refs/tags') || startsWith(github.head_ref, 'release-') || github.event_name == 'workflow_dispatch'
45+
tests-py:
46+
name: Test | ${{ matrix.python }}
18347
runs-on: ubuntu-latest
184-
48+
needs:
49+
- build
18550
strategy:
18651
matrix:
187-
arch:
188-
- aarch64
189-
- ppc64le
190-
- s390x
191-
# Building in QEMU is very slow, so parallelize the tasks.
192-
skip_image:
193-
- musllinux
194-
- manylinux
195-
196-
env:
197-
CIBW_ARCHS: ${{ matrix.arch }}
198-
CIBW_SKIP: "*${{ matrix.skip_image }}*"
199-
52+
python:
53+
- "3.10"
54+
- "3.11"
55+
- "3.12"
56+
- "3.13"
57+
- "3.14"
58+
- "pypy-3.10"
59+
- "pypy-3.11"
20060
steps:
201-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@v6
62+
- name: Restore build artifacts
63+
uses: actions/download-artifact@v6
20264
with:
203-
submodules: true
204-
- uses: actions/setup-python@v5
205-
with:
206-
python-version: ${{ env.PYTHON_VER }}
207-
208-
- name: Set up QEMU
209-
uses: docker/setup-qemu-action@v3
210-
211-
- name: Build wheels
212-
run: |
213-
python -m pip install -U cibuildwheel
214-
python -m cibuildwheel --output-dir wheelhouse
215-
216-
- name: List distributions
217-
run: ls -lR wheelhouse
218-
219-
- name: Upload wheels
220-
uses: actions/upload-artifact@v4
65+
name: build
66+
path: dist
67+
- name: Setup Python ${{ matrix.python }}
68+
uses: actions/setup-python@v6
22169
with:
222-
name: cibw-wheels-${{ matrix.arch }}-${{ matrix.skip_image }}
223-
path: wheelhouse/*.whl
70+
python-version: ${{ matrix.python }}
71+
- name: Install wheel
72+
run: python -m pip install dist/*.whl
73+
- name: Test
74+
run: python -m unittest discover tests -v
22475

225-
upload_pypi:
76+
publish:
22677
name: Publish to PyPI
22778
if: startsWith(github.ref, 'refs/tags')
22879
needs:
229-
- build_sdist
230-
- build_wheels
231-
- build_arch_wheels
80+
- build
81+
- tests-py
23282
runs-on: ubuntu-latest
23383
environment: publish
23484
permissions:
23585
id-token: write # This permission is mandatory for trusted publishing
236-
23786
steps:
238-
- name: Download wheels
239-
uses: actions/download-artifact@v4
87+
- name: Restore build artifacts
88+
uses: actions/download-artifact@v6
24089
with:
241-
pattern: cibw-*
90+
name: build
24291
path: dist
243-
merge-multiple: true
244-
24592
- name: List distributions
24693
run: ls -lR dist
247-
248-
- name: Upload to PyPI
94+
- name: Publish to PyPI
24995
uses: pypa/gh-action-pypi-publish@release/v1
25096
with:
251-
skip-existing: true
25297
verbose: true
25398
print-hash: true

.gitignore

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/.vscode
1+
/env
2+
__pycache__
3+
24
/build
35
/dist
4-
5-
__pycache__
6-
*.o
7-
*.pdb
8-
*.so
96
*.egg-info
7+
/.eggs
8+
9+
/.vscode
1010

11-
/LICENSE_zstd
11+
/src/pyzstd/_version.py

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## Unreleased
66

7+
- The project has been completely refactored to use the Zstandard implementation from the standard library ([PEP-784](https://peps.python.org/pep-0784/))
8+
- The refactor has some minor impact on public APIs, such as changing the exception raised on invalid input
9+
- Add `backports.zstd` dependency for Python before 3.14
10+
- Changes in build dependency: remove `setuptools` and C build toolchain, add `hatchling` and `hatch-vcs`
11+
- Remove git submodule usage
712
- Drop support for Python 3.9 and below
8-
- Build free-threaded wheels for CPython 3.13 and 3.14, even if the feature is not supported
9-
- Refactor SeekableZstdFile to make it independent of ZstdFile
1013

1114
## 0.18.0 (October 5, 2025)
1215

MANIFEST.in

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ an API style similar to the `bz2`, `lzma`, and `zlib` modules.
2828
> We recommend new projects to use the standard library, and existing ones to consider
2929
> migrating.
3030
>
31+
> `pyzstd` internally uses `compression.zstd` since version 0.19.0.
32+
>
3133
> See [`pyzstd`'s documentation][doc] for details and a migration guide.
3234
3335
[doc]: https://pyzstd.readthedocs.io/

0 commit comments

Comments
 (0)