{"id":5829,"library":"zipfile-deflate64","title":"zipfile-deflate64","description":"zipfile-deflate64 is a Python library that extends the standard `zipfile` module to enable extraction of ZIP archives compressed with the Deflate64 algorithm. This is particularly useful for handling large ZIP files (>2GB) created by tools like Microsoft Windows Explorer, which often use Deflate64 compression. It is currently at version 0.2.0 and has a release cadence driven by bug fixes and Python version compatibility updates.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/brianhelba/zipfile-deflate64","tags":["zip","archive","deflate64","compression","extraction","windows-zip"],"install":[{"cmd":"pip install zipfile-deflate64","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"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.","symbol":"zipfile_deflate64","correct":"import zipfile_deflate64"},{"note":"Using the standard `zipfile` module without first importing `zipfile_deflate64` will result in a `BadZipFile` or 'compression method not supported' error for Deflate64 archives.","wrong":"import zipfile\narchive = zipfile.ZipFile('path/to/deflate64_archive.zip', 'r')","symbol":"ZipFile","correct":"import zipfile_deflate64 as zipfile\narchive = zipfile.ZipFile('path/to/archive.zip', 'r')"}],"quickstart":{"code":"import os\nimport zipfile\nimport zipfile_deflate64 as custom_zipfile # This line enables Deflate64 support\n\n# Create a dummy (standard Deflate) zip file for demonstration\ndummy_zip_path = 'my_test_archive.zip'\nwith zipfile.ZipFile(dummy_zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:\n    zf.writestr('file1.txt', 'Hello from file 1!')\n    zf.writestr('folder/file2.txt', 'Content for file 2.')\n\n# Directory to extract to\nextract_dir = 'extracted_content'\nos.makedirs(extract_dir, exist_ok=True)\n\ntry:\n    # Use the patched zipfile API to extract\n    # This would work for both standard and Deflate64 archives after the import\n    with custom_zipfile.ZipFile(dummy_zip_path, 'r') as zip_ref:\n        zip_ref.extractall(extract_dir)\n    print(f\"Successfully extracted '{dummy_zip_path}' to '{extract_dir}'\")\n\n    # Verify extraction\n    print(f\"Content of {os.path.join(extract_dir, 'file1.txt')}: \")\n    with open(os.path.join(extract_dir, 'file1.txt'), 'r') as f:\n        print(f.read())\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Clean up dummy files\n    if os.path.exists(dummy_zip_path):\n        os.remove(dummy_zip_path)\n    if os.path.exists(os.path.join(extract_dir, 'file1.txt')):\n        os.remove(os.path.join(extract_dir, 'file1.txt'))\n    if os.path.exists(os.path.join(extract_dir, 'folder', 'file2.txt')):\n        os.remove(os.path.join(extract_dir, 'folder', 'file2.txt'))\n    if os.path.exists(os.path.join(extract_dir, 'folder')):\n        os.rmdir(os.path.join(extract_dir, 'folder'))\n    if os.path.exists(extract_dir):\n        os.rmdir(extract_dir)","lang":"python","description":"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."},"warnings":[{"fix":"Always 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`.","message":"The 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'.","severity":"gotcha","affected_versions":"All versions of Python's standard `zipfile` module."},{"fix":"Upgrade to version 0.2.0 or newer to ensure correct extraction behavior: `pip install --upgrade zipfile-deflate64`.","message":"Version 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.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Exercise caution in critical production environments. Regularly check for updates and review release notes when upgrading.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}