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.7, 3.8, and 3.9 supported, with manylinux2014 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 awful! 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 by Mark Adler, the 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.1.0.tar.gz (371.6 kB view details)

Uploaded Source

Built Distributions

File details

Details for the file zipfile-deflate64-0.1.0.tar.gz.

File metadata

  • Download URL: zipfile-deflate64-0.1.0.tar.gz
  • Upload date:
  • Size: 371.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

File hashes

Hashes for zipfile-deflate64-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d2627cdd8d88a17768256cae77c622972e3c1a0c06a78402567c56255135c038
MD5 604b75d5393a57917017e5644f2d854a
BLAKE2b-256 9892f87aa2b3a11705d417b9f466701d7e7744f5a1be68b97eafd8159a136e76

See more details on using hashes here.

File details

Details for the file zipfile_deflate64-0.1.0-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zipfile_deflate64-0.1.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 024b3f675df10309bed9cea3f38effb3910579f490eaa0cfdb0b8a18fd904727
MD5 e528b044bd67fa08b5e02293275060f1
BLAKE2b-256 79fc76d2dca94fe7ab5c0086820473b8d44e0fad3a0624b97f00ec37d58a43be

See more details on using hashes here.

File details

Details for the file zipfile_deflate64-0.1.0-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zipfile_deflate64-0.1.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ae17d6b816774ef31cc9c583712a8e5c7ad43f84eae74585ef137ec8c85d5a6
MD5 ddf24ba52ee850bbf5b06fe685a2d518
BLAKE2b-256 c3b19c58a2aa53958a134420a59a24f3e897d7eb45c5bbeacf7225974e48fb07

See more details on using hashes here.

File details

Details for the file zipfile_deflate64-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zipfile_deflate64-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c27bdca4a6e518993150d58230cc5c00ac96f6a2bad6e468073e4d2e447728c
MD5 74d76baf83d62dd23cdc3bb848fcc0ec
BLAKE2b-256 26d2f8a6658009fe4035836347d04d80776a10117307b043881ec90000536536

See more details on using hashes here.

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