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.

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-0.2.0.tar.gz (62.9 kB view hashes)

Uploaded Source

Built Distributions

zipfile_deflate64-0.2.0-cp310-cp310-win_amd64.whl (20.2 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

zipfile_deflate64-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (43.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

zipfile_deflate64-0.2.0-cp310-cp310-macosx_10_14_x86_64.whl (19.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.14+ x86-64

zipfile_deflate64-0.2.0-cp39-cp39-win_amd64.whl (20.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

zipfile_deflate64-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (43.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

zipfile_deflate64-0.2.0-cp39-cp39-macosx_10_14_x86_64.whl (19.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

zipfile_deflate64-0.2.0-cp38-cp38-win_amd64.whl (20.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

zipfile_deflate64-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (44.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

zipfile_deflate64-0.2.0-cp38-cp38-macosx_10_14_x86_64.whl (19.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

zipfile_deflate64-0.2.0-cp37-cp37m-win_amd64.whl (20.2 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

zipfile_deflate64-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (43.5 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

zipfile_deflate64-0.2.0-cp37-cp37m-macosx_10_14_x86_64.whl (19.1 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

zipfile_deflate64-0.2.0-cp36-cp36m-win_amd64.whl (20.5 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

zipfile_deflate64-0.2.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (43.7 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

zipfile_deflate64-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl (19.2 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

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