Install & Compatibility
Where this runs
tested against v0.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✓ 1.5s
py 3.11
✕ build_error
✕ build_error
py 3.12
✕ build_error
✕ build_error
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 1.7s
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
zipfile_deflate64
✓ import zipfile_deflate64
This import has the side effect of patching the standard `zipfile` module to add Deflate64 support. Afterwards, you can use `import zipfile` as normal, or directly use `zipfile_deflate64` as a re-export of the standard API.
ZipFile
✓ import zipfile_deflate64 as zipfile
archive = zipfile.ZipFile('path/to/archive.zip', 'r')
✗ import zipfile
archive = zipfile.ZipFile('path/to/deflate64_archive.zip', 'r')
Using the standard `zipfile` module without first importing `zipfile_deflate64` will result in a `BadZipFile` or 'compression method not supported' error for Deflate64 archives.
After installation, simply importing `zipfile_deflate64` (or aliasing it as `zipfile`) patches the standard library's `zipfile` module, allowing it to correctly handle Deflate64 compressed archives using its familiar API.
import os
import zipfile
import zipfile_deflate64 as custom_zipfile # This line enables Deflate64 support
# Create a dummy (standard Deflate) zip file for demonstration
dummy_zip_path = 'my_test_archive.zip'
with zipfile.ZipFile(dummy_zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
zf.writestr('file1.txt', 'Hello from file 1!')
zf.writestr('folder/file2.txt', 'Content for file 2.')
# Directory to extract to
extract_dir = 'extracted_content'
os.makedirs(extract_dir, exist_ok=True)
try:
# Use the patched zipfile API to extract
# This would work for both standard and Deflate64 archives after the import
with custom_zipfile.ZipFile(dummy_zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_dir)
print(f"Successfully extracted '{dummy_zip_path}' to '{extract_dir}'")
# Verify extraction
print(f"Content of {os.path.join(extract_dir, 'file1.txt')}: ")
with open(os.path.join(extract_dir, 'file1.txt'), 'r') as f:
print(f.read())
except Exception as e:
print(f"An error occurred: {e}")
finally:
# Clean up dummy files
if os.path.exists(dummy_zip_path):
os.remove(dummy_zip_path)
if os.path.exists(os.path.join(extract_dir, 'file1.txt')):
os.remove(os.path.join(extract_dir, 'file1.txt'))
if os.path.exists(os.path.join(extract_dir, 'folder', 'file2.txt')):
os.remove(os.path.join(extract_dir, 'folder', 'file2.txt'))
if os.path.exists(os.path.join(extract_dir, 'folder')):
os.rmdir(os.path.join(extract_dir, 'folder'))
if os.path.exists(extract_dir):
os.rmdir(extract_dir)
Debug
Known issues
gotchaThe standard `zipfile` module in Python does not natively support Deflate64 compression. Attempting to open or extract a Deflate64 ZIP archive without importing `zipfile_deflate64` will result in errors like `BadZipFile` or 'compression method not supported'.fixAlways include `import zipfile_deflate64` at the beginning of any script or module that needs to process Deflate64 ZIP files. Optionally, alias it: `import zipfile_deflate64 as zipfile`.
affects: All versions of Python's standard `zipfile` module.
breakingVersion 0.2.0 fixed significant bugs in `zipfile_deflate64.extractall` and `zipfile_deflate64.extract` (especially with larger files). Users on older versions might encounter issues or incorrect extractions.fixUpgrade to version 0.2.0 or newer to ensure correct extraction behavior: `pip install --upgrade zipfile-deflate64`.
affects: <0.2.0
gotchaThe library's PyPI page lists its development status as '3 - Alpha'. While it provides crucial functionality, this status indicates it may not be fully stable for all production scenarios and could introduce breaking changes in future minor versions.fixExercise caution in critical production environments. Regularly check for updates and review release notes when upgrading.
affects: All versions
Errors
Common errors & fixes
zipfile.BadZipFile: Invalid compression method (9)
The standard Python `zipfile` module does not support the Deflate64 compression algorithm (method 9), which is commonly used in large ZIP files.
fixImport `zipfile_deflate64` and call `zipfile_deflate64.enable()` to patch the standard library before attempting to open the Deflate64 ZIP file.
```python
import zipfile
import zipfile_deflate64
zipfile_deflate64.enable() # Enable Deflate64 support
try:
with zipfile.ZipFile("path/to/your/deflate64_archive.zip", "r") as zf:
zf.extractall("destination_folder")
print("Extraction successful.")
except zipfile.BadZipFile as e:
print(f"Extraction failed: {e}")
``` ModuleNotFoundError: No module named 'zipfile_deflate64'
The `zipfile-deflate64` library has not been installed in your current Python environment or is not accessible in the `PYTHONPATH`.
fixInstall the library using pip.
```bash
pip install zipfile-deflate64
```
AttributeError: module 'zipfile_deflate64' has no attribute 'ZipFile'
Developers mistakenly try to import `ZipFile` directly from `zipfile_deflate64`, instead of enabling the patch and then using the standard `zipfile.ZipFile` class.
fixCall `zipfile_deflate64.enable()` to patch the standard `zipfile` module, then use `zipfile.ZipFile` from the standard library as usual.
```python
import zipfile
import zipfile_deflate64
zipfile_deflate64.enable() # Patch the standard zipfile module
# Now use zipfile.ZipFile from the standard library
try:
with zipfile.ZipFile("path/to/your/archive.zip", "r") as zf:
zf.printdir()
except Exception as e:
print(f"Error: {e}")
``` Upgrade
Version history
0.2.0latest on PyPI · released Jan 5, 2022
Audit
Dependencies
No dependency data recorded yet.