Skip to main content

Extract Deflate64 ZIP archives with Python's zipfile API.

Project description

zipfile-deflate64

PyPI

Extract Deflate64 ZIP archives with Python's zipfile API.

⚠️ Note: This is a fork of zipfile_deflate64 (Apache 2.0) with updated zlib 1.3.1 for macOS build fix.

Installation

pip install zipfile-deflate64

Python 3.6, 3.7, 3.8, 3.9, and 3.10 are supported, with manylinux2014, macOS and Windows wheels published to PyPI.

Usage

Anywhere in a Python codebase:

import zipfile_deflate64  # This has the side effect of patching the zipfile module to support Deflate64

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

import zipfile_deflate64 as zipfile

zipfile.ZipFile(...)
...

Design Rationale

The Problem

Recent versions of Microsoft Windows Explorer use Deflate64 compression when creating ZIP files larger than 2GB. With the ubiquity of Windows and the ease of using "Sent to compressed folder", a majority of newly-created large ZIP files use Deflate64 compression.

However, support for Deflate64 in the open-source ecosystem is very poor! Most ZIP libraries have declined to implement Deflate64, citing its proprietary nature.

In the .NET ecosystem, the ZipArchive API supports decompression only. In Java, the Apache Commons Compress APIs support both compression and decompression.

The 7-Zip project probably provides the best general-purpose support for compressing and decompressing Deflate64, but there are several obstacles to general usability:

In the Python ecosystem in particular, there have been several unfulfilled requests ( [1] [2] [3] ) for Deflate64 decompression support.

A Solution

The best hope seems to be the infback9 extension to zlib. This was developed in 2003 by Mark Adler, an original author of zlib, and is kept in the source repository of zlib, but it is not officially supported and contains no build tooling and is not distributed with zlib packages. Additionally, infback9 provides only low-level support for working with Deflate64 bitstreams, with no support for the ZIP archive format (which is out of scope for zlib).

infback9's C-language API is relatively simple, but requires a non-trivial struct and function pointers for initialization and some explicit memory management operations (resizing allocated buffers and proving a Python-friendly malloc) to operate efficiently, so wrapping it with only ctypes seems to be inadequate.

To manage ZIP archive extraction operations, the Python standard library zipfile module provides the essential features and is already ubiquitous in availability and usage. However, zipfile is difficult to extend, as it hardcodes many conditionals for compression formats and does not provide capabilities for easily augmenting or replacing parts of it. Monkey-patching can overcome some of these problems, and the promise of a drop-in, API-compatible patch to a standard library module outweighed the engineering benefits of basing a solution off a more naturally extensible third-party ZIP manipulation package.

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_deflate64_macos-0.1.0.tar.gz (62.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zipfile_deflate64_macos-0.1.0-cp39-cp39-macosx_10_9_universal2.whl (28.4 kB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file zipfile_deflate64_macos-0.1.0.tar.gz.

File metadata

  • Download URL: zipfile_deflate64_macos-0.1.0.tar.gz
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for zipfile_deflate64_macos-0.1.0.tar.gz
Algorithm Hash digest
SHA256 52e44a7347c12b5323d6b531c4ddc66372202a81a418e6988649f7cbb5d36b8c
MD5 ffcbbf4cc09099b12b1a1f6e75f88f1a
BLAKE2b-256 3e36f72af3d4593130182960a3fdad2bb1ef339f2135fca4eec9c3fa2c4dcf1c

See more details on using hashes here.

File details

Details for the file zipfile_deflate64_macos-0.1.0-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for zipfile_deflate64_macos-0.1.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3593662154b02fb3dbcbdff306e95dd4e2a3665c6af7bf8adff5484dcfb14fee
MD5 9de0a9637e6c9f93f77c9fe8b9d74d59
BLAKE2b-256 1df6b9102cff7f3115936396f42ef25a9ada068e18078a2398e865c42b6e4b0f

See more details on using hashes here.

Supported by

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