Skip to content

Commit e4e829a

Browse files
committed
docs: document new libzstd version constraint behaviors
Closes #267.
1 parent 604a65a commit e4e829a

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

c-ext/backend_c.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ void zstd_module_init(PyObject *m) {
138138
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
139139
#endif
140140

141-
/* python-zstandard relies on unstable zstd C API features. This means
141+
/*
142+
python-zstandard relies on unstable zstd C API features. This means
142143
that changes in zstd may break expectations in python-zstandard.
143144
144145
python-zstandard is distributed with a copy of the zstd sources.
@@ -152,19 +153,25 @@ void zstd_module_init(PyObject *m) {
152153
153154
We detect this mismatch here and refuse to load the module if this
154155
scenario is detected.
156+
157+
Historically we required exact matches. But over the years the churn
158+
in libzstd became reasonable and we relaxed this constraint to a minimum
159+
version check. Our assumption going forward is that we will only rely on
160+
unstable C API features that are in reality stable for years.
155161
*/
156162
PyObject *features = NULL;
157163
PyObject *feature = NULL;
164+
unsigned zstd_version_no = ZSTD_versionNumber();
158165
unsigned zstd_version_min = 10506;
159166
// if either compile-time or runtime version of libzstd is lower than expected, abort initialization
160167
if (ZSTD_VERSION_NUMBER < zstd_version_min ||
161-
ZSTD_versionNumber() < zstd_version_min) {
168+
zstd_version_no < zstd_version_min) {
162169
PyErr_Format(
163170
PyExc_ImportError,
164171
"zstd C API versions mismatch; Python bindings were not "
165172
"compiled/linked against expected zstd version (%u returned by the "
166173
"lib, %u hardcoded in zstd headers, %u hardcoded in the cext)",
167-
ZSTD_versionNumber(), ZSTD_VERSION_NUMBER, zstd_version_min);
174+
zstd_version_no, ZSTD_VERSION_NUMBER, zstd_version_min);
168175
return;
169176
}
170177

docs/installing.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ All Install Arguments
6565
Attempt to link against the zstd library present on the system instead
6666
of the version distributed with the extension.
6767

68-
The Python extension only supports linking against a specific version of
69-
zstd. So if the system version differs from what is expected, a build
70-
or runtime error will result.
71-
7268
``--warning-as-errors``
7369
Treat all compiler warnings as errors.
7470

@@ -122,6 +118,11 @@ against. For best results, point this package at the exact same version of
122118
``libzstd`` that it bundles. See the bundled ``zstd/zstd.h`` or
123119
``zstd/zstd.c`` for which version that is.
124120

121+
A build or run-time error can occur if the version of ``libzstd`` being built
122+
against does not exactly match our bundled version. Historically, we required
123+
an exact version match. But in September 2025 we relaxed this constraint to
124+
only require a minimum version match.
125+
125126
When linking against an external ``libzstd``, not all package features may be
126127
available. Notably, the ``multi_compress_to_buffer()`` and
127128
``multi_decompress_to_buffer()`` APIs are not available, as these rely on private

docs/news.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Version History
5353
* `setup.py` now depends on `packaging` and uses `packaging.version.Version` for
5454
version comparisons. This removes some deprecation warnings from usage of
5555
legacy distutils `Version` classes.
56+
* Relax run-time libzstd version checking in C extension from exactly 1.5.7
57+
to >=1.5.6. (#254, #267)
5658

5759
0.24.0 (released 2025-08-17)
5860
============================

0 commit comments

Comments
 (0)