Skip to main content

Monkey patch the standard zipfile module to enable XZ support

Project description



Monkey patch the standard zipfile module to enable XZ support.

Based on zipfile-deflate64 and zipfile-zstandard, which provides similar functionality but for the deflate64 algorithm. Unlike zipfile-deflate64, this package supports both compression and decompression.

Note: if you need Python2, use zipfile39 instead (it is also compatible with Python3).

Note: XZ is based on LZMA2, so the compression ratio will be similar to ZIP_LZMA.


pip install zipfile-xz


Anywhere in a Python codebase:

import zipfile_xz  # This has the side effect of patching the zipfile module to support XZ

Alternatively, zipfile_ppmd re-exports the zipfile API, as a convenience:

import zipfile_xz as zipfile


Compression example:

import zipfile_xz as zipfile

zf = zipfile.ZipFile('/tmp/', 'w', zipfile.ZIP_XZ, compresslevel=6)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zipfile-xz- (3.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page