backports-zstd 1.0.0


pip install backports-zstd

  Latest version

Released: Oct 10, 2025

Project Links

Meta
Author: Rogdham
Requires Python: <3.14,>=3.9

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers

Topic
  • System :: Archiving :: Compression

Programming Language
  • Python
  • Python :: 3
  • Python :: 3 :: Only
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13

Install

Add the following dependency to your project:

backports.zstd ; python_version<'3.14'

…or just run pip install backports.zstd.

Usage

When importing a module needing Zstandard support, use a conditional import based on the version of Python. See below for examples.

zstd

import sys

if sys.version_info >= (3, 14):
    from compression import zstd
else:
    from backports import zstd


# use the zstd module, for example:
zstd.compress(b"Hello, world!")

Refer to the official Python documentation for usage of the module.

tarfile

import sys

if sys.version_info >= (3, 14):
    import tarfile
else:
    from backports.zstd import tarfile


# use the tarfile module, for example:
with tarfile.open("archive.tar.zst") as tar:
    tar.list()

This tarfile modules is backported from Python 3.14 and includes Zstandard-specific features such as: explicit modes for opening files (e.g. r:zstd), specific arguments (e.g. zstd_dict)… refer to the official Python documentation for more info.

Moreover, the CLI is available as well: python -m backports.zstd.tarfile.

zipfile

import sys

if sys.version_info >= (3, 14):
    import zipfile
else:
    from backports.zstd import zipfile


# use the zipfile module, for example:
with zipfile.ZipFile("archive.zip", "w") as zf:
    zf.writestr("hello.txt", "Hi!", zipfile.ZIP_ZSTANDARD)

This zipfile modules is backported from Python 3.14 and includes Zstandard-specific features such as the constant ZIP_ZSTANDARD to be used for compress_type… refer to the official Python documentation for more info.

Moreover, the CLI is available as well: python -m backports.zstd.zipfile.

shutil

import shutil
import sys

if sys.version_info < (3, 14):
    from backports.zstd import register_shutil
    register_shutil()

# use the shutil module, for example
shutil.unpack_archive('archive.tar.zst')

Calling the register_shutil function allows to create zstd'ed tar files using the "zstdtar" format, as well as unpack them.

It also overrides support for unpacking zip files, enabling the unpacking of zip archives that use Zstandard for compression.

Alternatively, call register_shutil(tar=False) or register_shutil(zip=False) to choose which archiving support to register.

FAQ

Who are you?

This project is created and maintained by Rogdham (maintainer of pyzstd, who helped with PEP-784 and integration of Zstandard into the standard library), with help from Emma Smith (author of PEP-784, who did most of the work of porting pyzstd into the standard library).

How is this backport constructed?

The aim is to be as close as possible to the upstream code of CPython.

The runtime code comes from CPython 3.14, with minor changes to support older versions of Python. For PyPy users, the C code has been ported to CFFI.

During the build phase, the project uses zstd (canonical implementation of Zstandard) as well as pythoncapi-compat (which handles some of the compatibility with older Python versions).

Tests come from CPython 3.14, with minor changes to support older versions of Python. Additional tests have been written specifically for backports.zstd.

The type hints for the standard library have been contributed to typeshed and also backported to backports.zstd.

Why can this library not be installed with Python 3.14?

This is on purpose. For Python 3.14 and later, use the compression.zstd module from the standard library.

If you want your code to be compatible with multiple Python versions, condition the usage of this library based on the Python version:

Can I use the libzstd version installed on my system?

The wheels distributed on PyPI include a static version of libzstd for ease of installation and reproducibility.

If you want to use libzstd installed on your system, pass the --system-zstd argument to the build backend. For example:

python -m pip install --config-settings=--build-option=--system-zstd ...
python -m build --wheel --config-setting=--build-option=--system-zstd ...

If you run the test suite, set the environment variable BACKPORTSZSTD_SKIP_EXTENSION_TEST=1 to skip tests that may fail when using the system library.

I found a bug

If you encounter any issues, please open a GitHub issue with a minimal reproducible example.

We will check if the issue is with backports.zstd or CPython. We have already reported and fixed a few issues in CPython this way!

Wheel compatibility matrix

Platform CPython 3.9 CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython (additional flags: t) 3.13 PyPy 3.10 (pp73) PyPy 3.11 (pp73)
macosx_10_13_x86_64
macosx_10_15_x86_64
macosx_10_9_x86_64
macosx_11_0_arm64
manylinux2010_i686
manylinux2014_aarch64
manylinux2014_ppc64le
manylinux2014_s390x
manylinux2014_x86_64
manylinux_2_12_i686
manylinux_2_17_aarch64
manylinux_2_17_ppc64le
manylinux_2_17_s390x
manylinux_2_17_x86_64
manylinux_2_28_aarch64
manylinux_2_28_i686
manylinux_2_28_ppc64le
manylinux_2_28_s390x
manylinux_2_28_x86_64
musllinux_1_2_aarch64
musllinux_1_2_i686
musllinux_1_2_ppc64le
musllinux_1_2_s390x
musllinux_1_2_x86_64
win32
win_amd64
win_arm64

Files in release

backports_zstd-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl (425.5KiB)
backports_zstd-1.0.0-cp310-cp310-macosx_11_0_arm64.whl (353.6KiB)
backports_zstd-1.0.0-cp310-cp310-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl (494.1KiB)
backports_zstd-1.0.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (464.4KiB)
backports_zstd-1.0.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (567.6KiB)
backports_zstd-1.0.0-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (625.8KiB)
backports_zstd-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (479.6KiB)
backports_zstd-1.0.0-cp310-cp310-musllinux_1_2_aarch64.whl (470.3KiB)
backports_zstd-1.0.0-cp310-cp310-musllinux_1_2_i686.whl (497.5KiB)
backports_zstd-1.0.0-cp310-cp310-musllinux_1_2_ppc64le.whl (571.9KiB)
backports_zstd-1.0.0-cp310-cp310-musllinux_1_2_s390x.whl (616.6KiB)
backports_zstd-1.0.0-cp310-cp310-musllinux_1_2_x86_64.whl (483.5KiB)
backports_zstd-1.0.0-cp310-cp310-win32.whl (281.8KiB)
backports_zstd-1.0.0-cp310-cp310-win_amd64.whl (306.2KiB)
backports_zstd-1.0.0-cp310-cp310-win_arm64.whl (281.9KiB)
backports_zstd-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl (425.5KiB)
backports_zstd-1.0.0-cp311-cp311-macosx_11_0_arm64.whl (353.6KiB)
backports_zstd-1.0.0-cp311-cp311-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl (494.1KiB)
backports_zstd-1.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (464.4KiB)
backports_zstd-1.0.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (567.6KiB)
backports_zstd-1.0.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (625.9KiB)
backports_zstd-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (479.6KiB)
backports_zstd-1.0.0-cp311-cp311-musllinux_1_2_aarch64.whl (470.3KiB)
backports_zstd-1.0.0-cp311-cp311-musllinux_1_2_i686.whl (497.5KiB)
backports_zstd-1.0.0-cp311-cp311-musllinux_1_2_ppc64le.whl (571.8KiB)
backports_zstd-1.0.0-cp311-cp311-musllinux_1_2_s390x.whl (616.7KiB)
backports_zstd-1.0.0-cp311-cp311-musllinux_1_2_x86_64.whl (483.5KiB)
backports_zstd-1.0.0-cp311-cp311-win32.whl (281.9KiB)
backports_zstd-1.0.0-cp311-cp311-win_amd64.whl (306.3KiB)
backports_zstd-1.0.0-cp311-cp311-win_arm64.whl (282.1KiB)
backports_zstd-1.0.0-cp312-cp312-macosx_10_13_x86_64.whl (425.8KiB)
backports_zstd-1.0.0-cp312-cp312-macosx_11_0_arm64.whl (353.7KiB)
backports_zstd-1.0.0-cp312-cp312-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl (494.5KiB)
backports_zstd-1.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (465.1KiB)
backports_zstd-1.0.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (568.0KiB)
backports_zstd-1.0.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (625.4KiB)
backports_zstd-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (482.6KiB)
backports_zstd-1.0.0-cp312-cp312-musllinux_1_2_aarch64.whl (471.0KiB)
backports_zstd-1.0.0-cp312-cp312-musllinux_1_2_i686.whl (497.9KiB)
backports_zstd-1.0.0-cp312-cp312-musllinux_1_2_ppc64le.whl (572.3KiB)
backports_zstd-1.0.0-cp312-cp312-musllinux_1_2_s390x.whl (616.1KiB)
backports_zstd-1.0.0-cp312-cp312-musllinux_1_2_x86_64.whl (487.0KiB)
backports_zstd-1.0.0-cp312-cp312-win32.whl (282.1KiB)
backports_zstd-1.0.0-cp312-cp312-win_amd64.whl (306.5KiB)
backports_zstd-1.0.0-cp312-cp312-win_arm64.whl (282.2KiB)
backports_zstd-1.0.0-cp313-cp313-macosx_10_13_x86_64.whl (425.3KiB)
backports_zstd-1.0.0-cp313-cp313-macosx_11_0_arm64.whl (353.3KiB)
backports_zstd-1.0.0-cp313-cp313-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl (493.8KiB)
backports_zstd-1.0.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (464.7KiB)
backports_zstd-1.0.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (567.7KiB)
backports_zstd-1.0.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (627.2KiB)
backports_zstd-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (479.3KiB)
backports_zstd-1.0.0-cp313-cp313-musllinux_1_2_aarch64.whl (470.3KiB)
backports_zstd-1.0.0-cp313-cp313-musllinux_1_2_i686.whl (497.3KiB)
backports_zstd-1.0.0-cp313-cp313-musllinux_1_2_ppc64le.whl (572.1KiB)
backports_zstd-1.0.0-cp313-cp313-musllinux_1_2_s390x.whl (617.7KiB)
backports_zstd-1.0.0-cp313-cp313-musllinux_1_2_x86_64.whl (483.5KiB)
backports_zstd-1.0.0-cp313-cp313-win32.whl (281.7KiB)
backports_zstd-1.0.0-cp313-cp313-win_amd64.whl (306.3KiB)
backports_zstd-1.0.0-cp313-cp313-win_arm64.whl (281.9KiB)
backports_zstd-1.0.0-cp313-cp313t-macosx_10_13_x86_64.whl (426.0KiB)
backports_zstd-1.0.0-cp313-cp313t-macosx_11_0_arm64.whl (354.0KiB)
backports_zstd-1.0.0-cp313-cp313t-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl (495.7KiB)
backports_zstd-1.0.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (464.4KiB)
backports_zstd-1.0.0-cp313-cp313t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (567.3KiB)
backports_zstd-1.0.0-cp313-cp313t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (624.9KiB)
backports_zstd-1.0.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (483.2KiB)
backports_zstd-1.0.0-cp313-cp313t-musllinux_1_2_aarch64.whl (470.7KiB)
backports_zstd-1.0.0-cp313-cp313t-musllinux_1_2_i686.whl (499.4KiB)
backports_zstd-1.0.0-cp313-cp313t-musllinux_1_2_ppc64le.whl (571.8KiB)
backports_zstd-1.0.0-cp313-cp313t-musllinux_1_2_s390x.whl (615.8KiB)
backports_zstd-1.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl (487.7KiB)
backports_zstd-1.0.0-cp313-cp313t-win32.whl (282.6KiB)
backports_zstd-1.0.0-cp313-cp313t-win_amd64.whl (307.4KiB)
backports_zstd-1.0.0-cp313-cp313t-win_arm64.whl (282.6KiB)
backports_zstd-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl (425.6KiB)
backports_zstd-1.0.0-cp39-cp39-macosx_11_0_arm64.whl (353.7KiB)
backports_zstd-1.0.0-cp39-cp39-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl (494.2KiB)
backports_zstd-1.0.0-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (464.6KiB)
backports_zstd-1.0.0-cp39-cp39-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (567.8KiB)
backports_zstd-1.0.0-cp39-cp39-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (626.0KiB)
backports_zstd-1.0.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (479.7KiB)
backports_zstd-1.0.0-cp39-cp39-musllinux_1_2_aarch64.whl (470.5KiB)
backports_zstd-1.0.0-cp39-cp39-musllinux_1_2_i686.whl (497.7KiB)
backports_zstd-1.0.0-cp39-cp39-musllinux_1_2_ppc64le.whl (572.0KiB)
backports_zstd-1.0.0-cp39-cp39-musllinux_1_2_s390x.whl (616.8KiB)
backports_zstd-1.0.0-cp39-cp39-musllinux_1_2_x86_64.whl (483.7KiB)
backports_zstd-1.0.0-cp39-cp39-win32.whl (281.9KiB)
backports_zstd-1.0.0-cp39-cp39-win_amd64.whl (306.2KiB)
backports_zstd-1.0.0-cp39-cp39-win_arm64.whl (282.0KiB)
backports_zstd-1.0.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl (400.2KiB)
backports_zstd-1.0.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl (331.4KiB)
backports_zstd-1.0.0-pp310-pypy310_pp73-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl (410.5KiB)
backports_zstd-1.0.0-pp310-pypy310_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (384.7KiB)
backports_zstd-1.0.0-pp310-pypy310_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (404.2KiB)
backports_zstd-1.0.0-pp310-pypy310_pp73-win_amd64.whl (292.7KiB)
backports_zstd-1.0.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl (400.1KiB)
backports_zstd-1.0.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl (331.3KiB)
backports_zstd-1.0.0-pp311-pypy311_pp73-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl (410.5KiB)
backports_zstd-1.0.0-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (384.7KiB)
backports_zstd-1.0.0-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (404.2KiB)
backports_zstd-1.0.0-pp311-pypy311_pp73-win_amd64.whl (292.7KiB)
backports_zstd-1.0.0.tar.gz (972.6KiB)
No dependencies